Michael Pasternak has posted comments on this change.
Change subject: restapi,engine: fix usb mapping on update vm call
......................................................................
Patch Set 2: I would prefer that you didn't submit this
(4 inline comments)
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/UsbResourceUtils.java
Line 5: import org.ovirt.engine.core.common.businessentities.UsbPolicy;
Line 6: import org.ovirt.engine.core.common.businessentities.VDSGroup;
Line 7: import org.ovirt.engine.core.compat.Version;
Line 8:
Line 9: public class UsbResourceUtils {
this is mapping logic, please move it to VmMapper and remove this util.
Line 10: public static UsbPolicy getUsbPolicyOnCreate(Usb usb, VDSGroup
vdsGroup) {
Line 11: UsbPolicy usbPolicy = null;
Line 12: if (usb == null || !usb.isSetEnabled() || !usb.isEnabled()) {
Line 13: usbPolicy = UsbPolicy.DISABLED;
....................................................
File
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/utils/test/UsbResourceUtilsTest.java
Line 9: import org.ovirt.engine.core.common.businessentities.UsbPolicy;
Line 10: import org.ovirt.engine.core.common.businessentities.VDSGroup;
Line 11: import org.ovirt.engine.core.compat.Version;
Line 12:
Line 13: public class UsbResourceUtilsTest {
please move these tests to VmMapperTest after you moving the code from this util
to VmMapper
Line 14: @Test
Line 15: public void getUsbPolicyNullUsb() {
Line 16: Usb usb = null;
Line 17: VDSGroup vdsGroup = new VDSGroup();
....................................................
File
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
Line 30:
Line 31: @Mapping(from = Template.class, to = VmTemplate.class)
Line 32: public static VmTemplate map(Template model, VmTemplate incoming) {
Line 33: // USB policy will be updated outside of this method because
there's
Line 34: // a different mapping for it on create and update VM
operations
the comment above ^ is irrelevant cause :
- add() using Template.class => VmStatic.class mapper
- update() using Template.class => VmTemplate.class
so you can easlly move enum mapping code from util to mappers
Line 35: VmTemplate entity = incoming != null ? incoming : new
VmTemplate();
Line 36: if (model.isSetName()) {
Line 37: entity.setname(model.getName());
Line 38: }
....................................................
File
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
Line 98: }
Line 99: @Mapping(from = VM.class, to = VmStatic.class)
Line 100: public static VmStatic map(VM vm, VmStatic template) {
Line 101: // USB policy will be updated outside of this method because
there's
Line 102: // a different mapping for it on create and update VM
operations
see my comment in TemplateMapper
Line 103: VmStatic staticVm = template != null ? template : new
VmStatic();
Line 104: if (vm.isSetName()) {
Line 105: staticVm.setvm_name(vm.getName());
Line 106: }
--
To view, visit http://gerrit.ovirt.org/9792
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: If74bf6ede2fc0f932db8dfcd7951b6bcf90b7744
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <[email protected]>
Gerrit-Reviewer: Arik Hadas <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches