List of usage examples for org.apache.commons.lang3.builder DiffResult getNumberOfDiffs
public int getNumberOfDiffs()
Returns the number of differences between the two objects.
From source file:com.infinities.skyport.compute.entity.patch.VolumeProductPatchBuilderTest.java
@Test public void testDiff() { VolumeProduct vp = VolumeProduct.getInstance("id", "name", "description", VolumeType.SSD, new Storage<Gigabyte>(5, new Gigabyte()), "currency", 5, 5, new Float(5), new Float(5)); vp.withMaxIopsRatio(1);/*from w ww . j a v a 2 s . com*/ vp.withMaxVolumeSize(new Storage<Gigabyte>(1, new Gigabyte())); vp.withMinVolumeSize(new Storage<Gigabyte>(1, new Gigabyte())); VolumeProduct updated = VolumeProduct.getInstance("id", "name", "description", VolumeType.SSD, new Storage<Gigabyte>(5, new Gigabyte()), "currency", 5, 5, new Float(5), new Float(5)); updated.withMaxIopsRatio(5); updated.withMaxVolumeSize(new Storage<Gigabyte>(100, new Gigabyte())); updated.withMinVolumeSize(new Storage<Gigabyte>(2, new Gigabyte())); DiffResult diffResult = builder.diff(vp, updated); assertEquals(3, diffResult.getNumberOfDiffs()); }
From source file:com.infinities.skyport.compute.entity.patch.SnapshotPatchBuilderTest.java
@Test public void testDiff() { Snapshot old = new Snapshot(); old.setCurrentState(SnapshotState.AVAILABLE); old.setDescription("description"); old.setName("name"); old.setOwner("owner"); old.setProgress("progress"); old.setProviderSnapshotId("providerSnapshotId"); old.setRegionId("regionId"); old.setSizeInGb(0);//from w w w .j a v a 2 s. co m old.setSnapshotTimestamp(0); old.setTag("key", "value"); old.setVisibleScope(VisibleScope.ACCOUNT_DATACENTER); old.setVolumeId("volumeId"); Snapshot updated = new Snapshot(); updated.setCurrentState(SnapshotState.DELETED); updated.setDescription("description1"); updated.setName("name1"); updated.setOwner("owner1"); updated.setProgress("progress1"); updated.setProviderSnapshotId("providerSnapshotId1"); updated.setRegionId("regionId1"); updated.setSizeInGb(1); updated.setSnapshotTimestamp(1); updated.setTag("key1", "value1"); updated.setVisibleScope(VisibleScope.ACCOUNT_GLOBAL); updated.setVolumeId("volumeId1"); DiffResult diffResult = builder.diff(old, updated); assertEquals(12, diffResult.getNumberOfDiffs()); }
From source file:com.infinities.skyport.compute.entity.patch.VirtualMachineProductPatchBuilderTest.java
@Test public void testDiff() { VirtualMachineProduct old = new VirtualMachineProduct(); old.setArchitectures(Architecture.I32); old.setCpuCount(0);//from ww w .j ava 2 s . com old.setDataCenterId("dataCenterId"); old.setDescription("description"); old.setName("name"); Map<String, String> providerMetadata = new HashMap<String, String>(); providerMetadata.put("key", "value"); old.setProviderMetadata(providerMetadata); old.setProviderProductId("providerProductId"); old.setRamSize(new Storage<Megabyte>(1, new Megabyte())); old.setRootVolumeSize(new Storage<Gigabyte>(1, new Gigabyte())); old.setStandardHourlyRate(0); old.setVisibleScope(VisibleScope.ACCOUNT_DATACENTER); VirtualMachineProduct updated = new VirtualMachineProduct(); updated.setArchitectures(Architecture.I64); updated.setCpuCount(1); updated.setDataCenterId("dataCenterId1"); updated.setDescription("description1"); updated.setName("name1"); Map<String, String> providerMetadata1 = new HashMap<String, String>(); providerMetadata1.put("key1", "value1"); updated.setProviderMetadata(providerMetadata1); updated.setProviderProductId("providerProductId1"); updated.setRamSize(new Storage<Megabyte>(2, new Megabyte())); updated.setRootVolumeSize(new Storage<Gigabyte>(2, new Gigabyte())); updated.setStandardHourlyRate(1); updated.setStatusDeprecated(); updated.setVisibleScope(VisibleScope.ACCOUNT_GLOBAL); DiffResult diffResult = builder.diff(old, updated); assertEquals(12, diffResult.getNumberOfDiffs()); }
From source file:com.infinities.skyport.compute.entity.patch.VolumePatchBuilderTest.java
@Test public void testDiff() { Volume old = new Volume(); old.setCreationTimestamp(0);//from w ww. ja va2 s. c om old.setCurrentState(VolumeState.AVAILABLE); old.setDeleteOnVirtualMachineTermination(false); old.setDescription("description"); old.setDeviceId("deviceId"); old.setFormat(VolumeFormat.BLOCK); old.setGuestOperatingSystem(Platform.CENT_OS); old.setIops(0); old.setMediaLink("mediaLink"); old.setName("name"); old.setProviderDataCenterId("dataCenterId"); old.setProviderProductId("providerProductId"); old.setProviderRegionId("regionId"); old.setProviderSnapshotId("snapshotId"); old.setProviderVirtualMachineId("serverId"); old.setProviderVlanId("providerVlanId"); old.setProviderVolumeId("providerVolumeId"); old.setRootVolume(false); old.setSize(new Storage<Gigabyte>(5, new Gigabyte())); old.setTag("key", "value"); old.setType(VolumeType.HDD); Volume updated = new Volume(); updated.setCreationTimestamp(1); updated.setCurrentState(VolumeState.DELETED); updated.setDeleteOnVirtualMachineTermination(true); updated.setDescription("description1"); updated.setDeviceId("deviceId1"); updated.setFormat(VolumeFormat.NFS); updated.setGuestOperatingSystem(Platform.COREOS); updated.setIops(1); updated.setMediaLink("mediaLink1"); updated.setName("name1"); updated.setProviderDataCenterId("dataCenterId1"); updated.setProviderProductId("providerProductId1"); updated.setProviderRegionId("regionId1"); updated.setProviderSnapshotId("snapshotId1"); updated.setProviderVirtualMachineId("serverId1"); updated.setProviderVlanId("providerVlanId1"); updated.setProviderVolumeId("providerVolumeId1"); updated.setRootVolume(true); updated.setSize(new Storage<Gigabyte>(6, new Gigabyte())); updated.setTag("key1", "value1"); updated.setType(VolumeType.SSD); DiffResult diffResult = builder.diff(old, updated); assertEquals(21, diffResult.getNumberOfDiffs()); }
From source file:com.infinities.skyport.compute.entity.patch.MachineImagePatchBuilderTest.java
@SuppressWarnings("deprecation") @Test// w w w. j a v a 2 s. c o m public void testDiff() { MachineImage old = new MachineImage(); old.setArchitecture(Architecture.I32); // updated.setCreationTimestamp(0); old.setCurrentState(MachineImageState.ACTIVE); old.setDescription("description"); old.setImageClass(ImageClass.KERNEL); old.associatedWith("kernelImageId"); old.setMinimumDiskSizeGb(0); old.setName("name"); old.setPlatform(Platform.CENT_OS); old.setProviderMachineImageId("providerMachineImageId"); old.setProviderOwnerId("providerOwnerId"); old.setProviderRegionId("providerRegionId"); old.withSoftware("software"); old.withStorageFormat(MachineImageFormat.AWS); old.setTag("key", "value"); old.withType(MachineImageType.STORAGE); old.withVisibleScope(VisibleScope.ACCOUNT_DATACENTER); Map<String, String> providerMetadata = new HashMap<String, String>(); providerMetadata.put("key", "value"); old.withProviderMetadata(providerMetadata); old.constrainedTo("dataCenterId"); old.createdAt(0); MachineImageVolume volume = MachineImageVolume.getInstance("deviceName", "snapshotId", 1, "volumeType", 1); List<MachineImageVolume> volumes = new ArrayList<MachineImageVolume>(); volumes.add(volume); old.withVolumes(volumes); MachineImage updated = new MachineImage(); updated.setArchitecture(Architecture.I64); // updated.setCreationTimestamp(0); updated.setCurrentState(MachineImageState.DELETED); updated.setDescription("description1"); updated.setImageClass(ImageClass.MACHINE); updated.associatedWith("kernelImageId1"); updated.setMinimumDiskSizeGb(1); updated.setName("name1"); updated.setPlatform(Platform.COREOS); updated.setProviderMachineImageId("providerMachineImageId1"); updated.setProviderOwnerId("providerOwnerId1"); updated.setProviderRegionId("providerRegionId1"); updated.withSoftware("software1"); updated.withStorageFormat(MachineImageFormat.NIMBULA); updated.setTag("key1", "value1"); updated.withType(MachineImageType.VOLUME); updated.withVisibleScope(VisibleScope.ACCOUNT_GLOBAL); Map<String, String> providerMetadata1 = new HashMap<String, String>(); providerMetadata1.put("key1", "value1"); updated.withProviderMetadata(providerMetadata1); updated.constrainedTo("dataCenterId1"); updated.createdAt(1); MachineImageVolume volume1 = MachineImageVolume.getInstance("deviceName1", "snapshotId1", 2, "volumeType1", 2); List<MachineImageVolume> updagedVolumes = new ArrayList<MachineImageVolume>(); updagedVolumes.add(volume1); updated.withVolumes(updagedVolumes); DiffResult diffResult = builder.diff(old, updated); assertEquals(20, diffResult.getNumberOfDiffs()); }
From source file:com.infinities.skyport.compute.entity.patch.VirtualMachinePatchBuilderTest.java
@Test public void testDiff() { VirtualMachine old = new VirtualMachine(); old.setAffinityGroupId("affinityGroupId"); old.setArchitecture(Architecture.I32); old.setClientRequestToken("clientRequestToken"); old.setClonable(false);// w w w . ja v a 2 s.c o m old.setCreationTimestamp(0); old.setCurrentState(VmState.ERROR); old.setDescription("description"); old.setImagable(false); old.setIoOptimized(false); old.setIpForwardingAllowed(false); old.setLabels(new String[] { "label" }); old.setLastBootTimestamp(0); old.setLastPauseTimestamp(0); old.setLifecycle(VirtualMachineLifecycle.NORMAL); old.setName("name"); old.setPausable(false); old.setPersistent(false); old.setPlatform(Platform.CENT_OS); old.setPrivateAddresses(new RawAddress("0.0.0.0")); old.setPrivateDnsAddress("old.private.dns"); old.setProductId("productId"); old.setProviderAssignedIpAddressId("providerAssignedIpAddressId"); old.setProviderDataCenterId("providerDataCenterId"); old.setProviderFirewallIds(new String[] { "providerFirewallid" }); old.setProviderHostStatus(VmStatus.IMPAIRED); old.setProviderKernelImageId("providerKernelImageId"); old.setProviderKeypairId("providerKeypairId"); old.setProviderMachineImageId("providerMachineImageId"); old.setProviderNetworkInterfaceIds(new String[] { "providerNetworkInterfaceId" }); old.setProviderOwnerId("providerOwnerId"); old.setProviderRamdiskImageId("providerRamdiskImageId"); old.setProviderRegionId("providerRegionId"); old.setProviderRoleId("roleId"); old.setProviderShellKeyIds("keyIds"); old.setProviderSubnetId("providerSubnetId"); old.setProviderVirtualMachineId("providerVirtualMachineId"); old.setProviderVlanId("providerVlanId"); old.setProviderVmStatus(VmStatus.IMPAIRED); old.setProviderVolumeIds("id"); old.setPublicAddresses(new RawAddress("0.0.0.0")); old.setPublicDnsAddress("old.public.dns"); old.setRebootable(false); old.setResourcePoolId("resourcePoolId"); old.setRootPassword("rootPassword"); old.setRootUser("rootUser"); old.setSpotRequestId("spotRequestId"); old.setStateReasonMessage("stateReasonMessage"); old.setTag("key", "value"); old.setTerminationTimestamp(0); old.setVisibleScope(VisibleScope.ACCOUNT_DATACENTER); Volume volume = new Volume(); volume.setCreationTimestamp(0); volume.setCurrentState(VolumeState.AVAILABLE); volume.setDeleteOnVirtualMachineTermination(false); volume.setDescription("description"); volume.setDeviceId("deviceId"); volume.setFormat(VolumeFormat.BLOCK); volume.setGuestOperatingSystem(Platform.CENT_OS); volume.setIops(0); volume.setMediaLink("mediaLink"); volume.setName("name"); volume.setProviderDataCenterId("dataCenterId"); volume.setProviderProductId("providerProductId"); volume.setProviderRegionId("regionId"); volume.setProviderSnapshotId("snapshotId"); volume.setProviderVirtualMachineId("serverId"); volume.setProviderVlanId("providerVlanId"); volume.setProviderVolumeId("providerVolumeId"); volume.setRootVolume(false); volume.setSize(new Storage<Gigabyte>(5, new Gigabyte())); volume.setTag("key", "value"); volume.setType(VolumeType.HDD); old.setVolumes(new Volume[] { volume }); VirtualMachine updated = new VirtualMachine(); updated.setAffinityGroupId("affinityGroupId1"); updated.setArchitecture(Architecture.I64); updated.setClientRequestToken("clientRequestToken1"); updated.setClonable(true); updated.setCreationTimestamp(1); updated.setCurrentState(VmState.PAUSED); updated.setDescription("description1"); updated.setImagable(true); updated.setIoOptimized(true); updated.setIpForwardingAllowed(true); updated.setLabels(new String[] { "label1" }); updated.setLastBootTimestamp(1); updated.setLastPauseTimestamp(1); updated.setLifecycle(VirtualMachineLifecycle.SPOT); updated.setName("name1"); updated.setPausable(true); updated.setPersistent(true); updated.setPlatform(Platform.COREOS); updated.setPrivateAddresses(new RawAddress("0.0.0.1")); updated.setPrivateDnsAddress("old.private.dns1"); updated.setProductId("productId1"); updated.setProviderAssignedIpAddressId("providerAssignedIpAddressId1"); updated.setProviderDataCenterId("providerDataCenterId1"); updated.setProviderFirewallIds(new String[] { "providerFirewallid1" }); updated.setProviderHostStatus(VmStatus.INSUFFICIENT_DATA); updated.setProviderKernelImageId("providerKernelImageId1"); updated.setProviderKeypairId("providerKeypairId1"); updated.setProviderMachineImageId("providerMachineImageId1"); updated.setProviderNetworkInterfaceIds(new String[] { "providerNetworkInterfaceId1" }); updated.setProviderOwnerId("providerOwnerId1"); updated.setProviderRamdiskImageId("providerRamdiskImageId1"); updated.setProviderRegionId("providerRegionId1"); updated.setProviderRoleId("roleId1"); updated.setProviderShellKeyIds("keyIds1"); updated.setProviderSubnetId("providerSubnetId1"); updated.setProviderVirtualMachineId("providerVirtualMachineId1"); updated.setProviderVlanId("providerVlanId1"); updated.setProviderVmStatus(VmStatus.INSUFFICIENT_DATA); updated.setProviderVolumeIds("id1"); updated.setPublicAddresses(new RawAddress("0.0.0.1")); updated.setPublicDnsAddress("old.public.dns1"); updated.setRebootable(true); updated.setResourcePoolId("resourcePoolId1"); updated.setRootPassword("rootPassword1"); updated.setRootUser("rootUser1"); updated.setSpotRequestId("spotRequestId1"); updated.setStateReasonMessage("stateReasonMessage1"); updated.setTag("key1", "value1"); updated.setTerminationTimestamp(1); updated.setVisibleScope(VisibleScope.ACCOUNT_GLOBAL); Volume updatedVolume = new Volume(); updatedVolume.setCreationTimestamp(1); updatedVolume.setCurrentState(VolumeState.DELETED); updatedVolume.setDeleteOnVirtualMachineTermination(true); updatedVolume.setDescription("description1"); updatedVolume.setDeviceId("deviceId1"); updatedVolume.setFormat(VolumeFormat.NFS); updatedVolume.setGuestOperatingSystem(Platform.COREOS); updatedVolume.setIops(1); updatedVolume.setMediaLink("mediaLink1"); updatedVolume.setName("name1"); updatedVolume.setProviderDataCenterId("dataCenterId1"); updatedVolume.setProviderProductId("providerProductId1"); updatedVolume.setProviderRegionId("regionId1"); updatedVolume.setProviderSnapshotId("snapshotId1"); updatedVolume.setProviderVirtualMachineId("serverId1"); updatedVolume.setProviderVlanId("providerVlanId1"); updatedVolume.setProviderVolumeId("providerVolumeId1"); updatedVolume.setRootVolume(true); updatedVolume.setSize(new Storage<Gigabyte>(6, new Gigabyte())); updatedVolume.setTag("key1", "value1"); updatedVolume.setType(VolumeType.SSD); updated.setVolumes(new Volume[] { updatedVolume }); DiffResult diffResult = builder.diff(old, updated); // ProviderVolumeIds cannot be got directly assertEquals(50, diffResult.getNumberOfDiffs()); }