Ravi Nori has posted comments on this change.
Change subject: engine : Validate parameter in canDoAction
......................................................................
Patch Set 5:
(4 comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
Line 144:
Line 145: private Map<Guid, CommandBase<?>> childCommandsMap = new
HashMap<>();
Line 146: private Map<Guid, Pair<VdcActionType, VdcActionParametersBase>>
childCommandInfoMap = new HashMap<>();
Line 147:
Line 148: @Parameters(type = Parameters.Type.common)
They are common to all actions, not all of them are required. If I mark them as
required lots of JUnit tests fail as they dont sent all these parameters when
invoking the command using mock parameters.
Line 149: final Parameter[] commonParameters = {
Line 150: CoreParameters.GUID_ID,
Line 151: CoreParameters.SESSION_ID,
Line 152: CoreParameters.PARAMETERS_CURRENT_USER,
Line 145: private Map<Guid, CommandBase<?>> childCommandsMap = new
HashMap<>();
Line 146: private Map<Guid, Pair<VdcActionType, VdcActionParametersBase>>
childCommandInfoMap = new HashMap<>();
Line 147:
Line 148: @Parameters(type = Parameters.Type.common)
Line 149: final Parameter[] commonParameters = {
they cant be private, throws IllegalAccessException. Currently walking through
inheritance
public static final so it can be accessed from ParameterValidator. Everything
else fails
Line 150: CoreParameters.GUID_ID,
Line 151: CoreParameters.SESSION_ID,
Line 152: CoreParameters.PARAMETERS_CURRENT_USER,
Line 153: CoreParameters.SHOULD_BE_LOGGED,
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/Parameters.java
Line 7:
Line 8: @Target(ElementType.FIELD)
Line 9: @Retention(RetentionPolicy.RUNTIME)
Line 10: public @interface Parameters {
Line 11: public enum Type {optional, required, common};
They are required by some commands and not always passed from Junit tests.
Line 12: Type type() default Type.required;
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ParametersValidator.java
Line 20: public static void validateParameters(QueriesCommandBase cmd) {
Line 21: validateParameters(getCommandParameters(cmd),
cmd.getParameters());
Line 22: }
Line 23:
Line 24: public static void validateParameters(CommandBase cmd) {
If I mark the parameters as public static final I can do the above
Line 25: validateParameters(getCommandParameters(cmd),
cmd.getParameters());
Line 26: }
Line 27:
Line 28: private static CommandParameters getCommandParameters(Object cmd) {
--
To view, visit http://gerrit.ovirt.org/21485
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I15566c9177da28b2d47bbb6018fbfb61defcf3da
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ravi Nori <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Ravi Nori <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches