From 98b3105669fdff75f6fe5355bc83d049b400a152 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 30 Jul 2015 15:21:42 -0700 Subject: [PATCH] Address error-prone errors Mostly of the form, Collection.size() >= 0. --- .../org/jclouds/cloudstack/features/AddressApiLiveTest.java | 2 +- .../org/jclouds/cloudstack/features/EventApiLiveTest.java | 4 ++-- .../org/jclouds/cloudstack/features/FirewallApiLiveTest.java | 2 +- .../jclouds/cloudstack/features/GlobalAlertApiLiveTest.java | 2 +- .../jclouds/cloudstack/features/GlobalUsageApiLiveTest.java | 2 +- .../org/jclouds/cloudstack/features/GuestOSApiLiveTest.java | 4 ++-- .../jclouds/cloudstack/features/HypervisorApiLiveTest.java | 2 +- .../jclouds/cloudstack/features/LoadBalancerApiLiveTest.java | 2 +- .../java/org/jclouds/cloudstack/features/NATApiLiveTest.java | 2 +- .../cloudstack/features/VirtualMachineApiLiveTest.java | 4 ++-- .../java/org/jclouds/cloudstack/features/ZoneApiLiveTest.java | 4 ++-- .../nova/v2_0/compute/options/NovaTemplateOptions.java | 2 +- .../openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java | 2 +- .../v1/features/LoadBalancerApiLiveTest.java | 2 +- .../cloudloadbalancers/v1/features/NodeApiLiveTest.java | 2 +- .../jclouds/compute/internal/BaseComputeServiceLiveTest.java | 2 +- .../org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java | 2 +- .../org/jclouds/softlayer/features/AccountApiLiveTest.java | 2 +- .../org/jclouds/softlayer/features/DatacenterApiLiveTest.java | 2 +- .../softlayer/features/SoftwareDescriptionApiLiveTest.java | 2 +- 20 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressApiLiveTest.java index dc685a67e6..5b77c4a94e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressApiLiveTest.java @@ -71,7 +71,7 @@ public class AddressApiLiveTest extends BaseCloudStackApiLiveTest { return; Set response = client.getAddressApi().listPublicIPAddresses(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (PublicIPAddress ip : response) { PublicIPAddress newDetails = getOnlyElement(client.getAddressApi().listPublicIPAddresses( ListPublicIPAddressesOptions.Builder.id(ip.getId()))); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java index 2f4cdefd26..10086f9566 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java @@ -33,7 +33,7 @@ public class EventApiLiveTest extends BaseCloudStackApiLiveTest { public void testlistEventTypes() throws Exception { final Set response = client.getEventApi().listEventTypes(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (String type : response) { checkEventType(type); } @@ -42,7 +42,7 @@ public class EventApiLiveTest extends BaseCloudStackApiLiveTest { public void testlistEvents() throws Exception { final Set response = client.getEventApi().listEvents(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (Event event : response) { checkEvent(event); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java index a96fad8673..13269a7be5 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java @@ -115,7 +115,7 @@ public class FirewallApiLiveTest extends BaseCloudStackApiLiveTest { public void testListPortForwardingRules() throws Exception { Set response = client.getFirewallApi().listPortForwardingRules(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (final PortForwardingRule rule : response) { checkPortForwardingRule(rule); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertApiLiveTest.java index 84b460282d..0efe23250f 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertApiLiveTest.java @@ -38,7 +38,7 @@ public class GlobalAlertApiLiveTest extends BaseCloudStackApiLiveTest { final Set response = globalAdminClient.getAlertClient().listAlerts(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); int count = 0; for (Alert alert : response) { assertNotNull(alert.getDescription()); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java index 14e48e7267..2770c34fe1 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java @@ -52,7 +52,7 @@ public class GlobalUsageApiLiveTest extends BaseCloudStackApiLiveTest { Set records = globalAdminClient.getUsageClient().listUsageRecords(start, end, ListUsageRecordsOptions.NONE); assertNotNull(records); - assertTrue(records.size() >= 0); + assertTrue(records.size() > 0); } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSApiLiveTest.java index 43c0d3ac55..d5afd7f070 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSApiLiveTest.java @@ -38,7 +38,7 @@ public class GuestOSApiLiveTest extends BaseCloudStackApiLiveTest { public void testListOSTypes() throws Exception { Set response = client.getGuestOSApi().listOSTypes(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (OSType type : response) { OSType newDetails = getOnlyElement(client.getGuestOSApi().listOSTypes( ListOSTypesOptions.Builder.id(type.getId()))); @@ -50,7 +50,7 @@ public class GuestOSApiLiveTest extends BaseCloudStackApiLiveTest { public void testListOSCategories() throws Exception { Map response = client.getGuestOSApi().listOSCategories(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (Entry category : response.entrySet()) { checkOSCategory(category); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorApiLiveTest.java index 13400fedef..57c41baeaf 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorApiLiveTest.java @@ -33,7 +33,7 @@ public class HypervisorApiLiveTest extends BaseCloudStackApiLiveTest { public void testListHypervisors() throws Exception { Set response = client.getHypervisorApi().listHypervisors(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (Zone zone : client.getZoneApi().listZones()) { Set zoneHype = client.getHypervisorApi().listHypervisorsInZone(zone.getId()); assert response.containsAll(zoneHype); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerApiLiveTest.java index dbc624be5c..8a02b49fca 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerApiLiveTest.java @@ -191,7 +191,7 @@ public class LoadBalancerApiLiveTest extends BaseCloudStackApiLiveTest { public void testListLoadBalancerRules() throws Exception { Set response = client.getLoadBalancerApi().listLoadBalancerRules(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (LoadBalancerRule rule : response) { LoadBalancerRule newDetails = findRuleWithId(rule.getId()); assertEquals(rule.getId(), newDetails.getId()); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATApiLiveTest.java index 2ecd4b6bfa..583f3cfb6f 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATApiLiveTest.java @@ -38,7 +38,7 @@ public class NATApiLiveTest extends BaseCloudStackApiLiveTest { public void testListIPForwardingRules() throws Exception { Set response = client.getNATApi().listIPForwardingRules(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (IPForwardingRule rule : response) { IPForwardingRule newDetails = getOnlyElement(client.getNATApi().listIPForwardingRules( ListIPForwardingRulesOptions.Builder.id(rule.getId()))); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineApiLiveTest.java index 81908afdd6..e7c60b0719 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineApiLiveTest.java @@ -335,7 +335,7 @@ public class VirtualMachineApiLiveTest extends BaseCloudStackApiLiveTest { public void testListVirtualMachines() throws Exception { Set response = client.getVirtualMachineApi().listVirtualMachines(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (VirtualMachine vm : response) { VirtualMachine newDetails = getOnlyElement(client.getVirtualMachineApi().listVirtualMachines( ListVirtualMachinesOptions.Builder.id(vm.getId()))); @@ -392,7 +392,7 @@ public class VirtualMachineApiLiveTest extends BaseCloudStackApiLiveTest { } } - assert vm.getSecurityGroups() != null && vm.getSecurityGroups().size() >= 0 : vm; + assert vm.getSecurityGroups() != null && vm.getSecurityGroups().size() > 0 : vm; assert vm.getHypervisor() != null : vm; } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneApiLiveTest.java index ae1b4806a0..fa0da5f75c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneApiLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneApiLiveTest.java @@ -58,8 +58,8 @@ public class ZoneApiLiveTest extends BaseCloudStackApiLiveTest { break; case BASIC: assert zone.getVLAN() == null : zone; - assert zone.getDNS().size() >= 0 : zone; - assert zone.getInternalDNS().size() >= 0 : zone; + assert zone.getDNS().size() > 0 : zone; + assert zone.getInternalDNS().size() > 0 : zone; assert zone.getDomain() == null : zone; assert zone.getDomainId() == null : zone; assert zone.getGuestCIDRAddress() == null : zone; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java index a6b1ed63c7..d8939ad499 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java @@ -113,7 +113,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public int hashCode() { return Objects.hashCode(super.hashCode(), autoAssignFloatingIp, floatingIpPoolNames, generateKeyPair, keyPairName, - userData, diskConfig, configDrive, novaNetworks, availabilityZone); + Arrays.hashCode(userData), diskConfig, configDrive, novaNetworks, availabilityZone); } @Override diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java index 27eee5a726..252091aa63 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java @@ -50,7 +50,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest { FloatingIPApi api = apiOption.get(); Set response = api.list().toSet(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (FloatingIP ip : response) { FloatingIP newDetails = api.get(ip.getId()); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApiLiveTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApiLiveTest.java index cde046bd94..9cdea3e519 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApiLiveTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApiLiveTest.java @@ -109,7 +109,7 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest { Set response = api.getLoadBalancerApi(region).list().concat().toSet(); assertNotNull(response); - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (LoadBalancer lb : response) { if (!lbs.contains(lb)) diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiLiveTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiLiveTest.java index c82898d7ac..8dd8a9b592 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiLiveTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiLiveTest.java @@ -107,7 +107,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest { for (LoadBalancer lb : nodes.keySet()) { Set response = api.getNodeApi(lb.getRegion(), lb.getId()).list().concat().toSet(); assert null != response; - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (Node n : response) { assert n.getId() != -1 : n; assert n.getCondition() != null : n; diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index 49033d2f11..f1af0b1838 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -844,7 +844,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte for (Hardware hardware : client.listHardwareProfiles()) { assert hardware.getProviderId() != null : hardware; assert getCores(hardware) > 0 : hardware; - assert hardware.getVolumes().size() >= 0 : hardware; + assert hardware.getVolumes().size() > 0 : hardware; assert hardware.getRam() > 0 : hardware; assertEquals(hardware.getType(), ComputeType.HARDWARE); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java index d6c6b14fcb..e7d229c2ef 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java @@ -52,7 +52,7 @@ public class AWSInstanceApiLiveTest extends BaseComputeServiceContextLiveTest { for (String region : view.unwrapApi(AWSEC2Api.class).getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); - assert allResults.size() >= 0 : allResults.size(); + assert allResults.size() > 0 : allResults.size(); } } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java index c53fef48d2..6cc1b2260f 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java @@ -45,7 +45,7 @@ public class AccountApiLiveTest extends BaseSoftLayerApiLiveTest { @Test public void testListVirtualGuests() throws Exception { Set response = api().listVirtualGuests(); - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (VirtualGuest vg : response) { checkVirtualGuest(vg); } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java index 0cf933878b..627012947c 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java @@ -39,7 +39,7 @@ public class DatacenterApiLiveTest extends BaseSoftLayerApiLiveTest { public void testListDatacenters() { Set response = api().listDatacenters(); assertNotNull(response); - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); for (Datacenter vg : response) { Datacenter newDetails = api().getDatacenter(vg.getId()); assertEquals(vg.getId(), newDetails.getId()); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/SoftwareDescriptionApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/SoftwareDescriptionApiLiveTest.java index 0948c6f0ef..2ed57973cf 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/SoftwareDescriptionApiLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/SoftwareDescriptionApiLiveTest.java @@ -33,7 +33,7 @@ public class SoftwareDescriptionApiLiveTest extends BaseSoftLayerApiLiveTest { public void testGetAllObjects() { Set response = api().getAllObjects(); assertNotNull(response); - assertTrue(response.size() >= 0); + assertTrue(response.size() > 0); } private SoftwareDescriptionApi api() {