From 84fc104a31598c6c6c98f839cf03d876f1c4cb75 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 20 Mar 2012 11:59:58 -0700 Subject: [PATCH] Issue 871: renamed LocationPredicate to what it is --- ...rentOrIsGrandparentOfCurrentLocation.java} | 6 ++-- .../domain/internal/TemplateBuilderImpl.java | 2 +- ...OrIsGrandparentOfCurrentLocationTest.java} | 32 +++++++++---------- .../internal/TemplateBuilderImplTest.java | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) rename compute/src/main/java/org/jclouds/compute/domain/internal/{LocationPredicate.java => NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java} (91%) rename compute/src/test/java/org/jclouds/compute/domain/internal/{LocationPredicateTest.java => NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest.java} (74%) diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java similarity index 91% rename from compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java rename to compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java index 4c9edee7d7..89cf0cbe84 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java @@ -38,10 +38,10 @@ import com.google.common.collect.ImmutableSet.Builder; * * If the input location equals, is a parent or grandparent of the specified location, then we are ok. */ -public class LocationPredicate implements Predicate { +public class NullEqualToIsParentOrIsGrandparentOfCurrentLocation implements Predicate { private final Supplier locationSupplier; - public LocationPredicate(Supplier locationSupplier) { + public NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Supplier locationSupplier) { this.locationSupplier = locationSupplier; } @@ -84,6 +84,6 @@ public class LocationPredicate implements Predicate { @Override public String toString() { // not calling .get() here, as it could accidentally cause eager api fetch - return "equalsParentOrGrandparentOfCurrentLocation()"; + return "nullEqualToIsParentOrIsGrandparentOfCurrentLocation()"; } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index 88cb13c99a..cce33f62c4 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -133,7 +133,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { this.defaultTemplateProvider = defaultTemplateProvider; } - final Predicate locationPredicate = new LocationPredicate(new Supplier(){ + final Predicate locationPredicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(new Supplier(){ @Override public Location get() { diff --git a/compute/src/test/java/org/jclouds/compute/domain/internal/LocationPredicateTest.java b/compute/src/test/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest.java similarity index 74% rename from compute/src/test/java/org/jclouds/compute/domain/internal/LocationPredicateTest.java rename to compute/src/test/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest.java index a949a33301..66876f3a4c 100644 --- a/compute/src/test/java/org/jclouds/compute/domain/internal/LocationPredicateTest.java +++ b/compute/src/test/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest.java @@ -34,8 +34,8 @@ import com.google.common.base.Suppliers; * * @author Adrian Cole */ -@Test(testName = "LocationPredicateTest") -public class LocationPredicateTest { +@Test(testName = "NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest") +public class NullEqualToIsParentOrIsGrandparentOfCurrentLocationTest { Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("aws-ec2").description("aws-ec2").build(); Location region = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description("us-east-1") @@ -61,7 +61,7 @@ public class LocationPredicateTest { * If the current location id is null, then we don't care where to launch a */ public void testReturnTrueWhenIDontSpecifyALocation() { - LocationPredicate predicate = new LocationPredicate(Suppliers. ofInstance(null)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers. ofInstance(null)); Hardware md = new HardwareBuilder().id("foo").location(region).build(); assertTrue(predicate.apply(md)); } @@ -70,7 +70,7 @@ public class LocationPredicateTest { * If the input location is null, then the data isn't location sensitive */ public void testReturnTrueWhenISpecifyALocationAndInputLocationIsNull() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(region)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(region)); Hardware md = new HardwareBuilder().id("foo").location(null).build(); assertTrue(predicate.apply(md)); } @@ -79,14 +79,14 @@ public class LocationPredicateTest { * If the input location is null, then the data isn't location sensitive */ public void testReturnTrueWhenIDontSpecifyALocationAndInputLocationIsNull() { - LocationPredicate predicate = new LocationPredicate(Suppliers. ofInstance(null)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers. ofInstance(null)); Hardware md = new HardwareBuilder().id("foo").location(null).build(); assertTrue(predicate.apply(md)); } @Test public void testReturnTrueWhenISpecifyARegionAndInputLocationIsProvider() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(region)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(region)); Hardware md = new HardwareBuilder().id("foo").location(provider).build(); assertTrue(predicate.apply(md)); } @@ -96,7 +96,7 @@ public class LocationPredicateTest { */ @Test public void testReturnFalseWhenISpecifyALocationWhichTheSameScopeByNotEqualToInputLocationAndParentsAreNull() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(region)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(region)); Hardware md = new HardwareBuilder().id("foo").location(otherRegion).build(); assertFalse(predicate.apply(md)); } @@ -105,7 +105,7 @@ public class LocationPredicateTest { * If the input location is null, then the data isn't location sensitive */ public void testReturnFalseWhenISpecifyALocationWhichTheSameScopeByNotEqualToInputLocationAndParentsAreNotNull() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(zone)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(zone)); Hardware md = new HardwareBuilder().id("foo").location(otherZone).build(); assertFalse(predicate.apply(md)); } @@ -115,7 +115,7 @@ public class LocationPredicateTest { * ok. */ public void testReturnTrueWhenISpecifyALocationWhichIsAChildOfInput() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(zone)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(zone)); Hardware md = new HardwareBuilder().id("foo").location(region).build(); assertTrue(predicate.apply(md)); } @@ -125,7 +125,7 @@ public class LocationPredicateTest { * ok. */ public void testReturnFalseWhenISpecifyALocationWhichIsNotAChildOfInput() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(zone)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(zone)); Hardware md = new HardwareBuilder().id("foo").location(otherRegion).build(); assertFalse(predicate.apply(md)); } @@ -135,7 +135,7 @@ public class LocationPredicateTest { * are ok. */ public void testReturnTrueWhenISpecifyALocationWhichIsAGrandChildOfInput() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(host)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(host)); Hardware md = new HardwareBuilder().id("foo").location(host).build(); assertTrue(predicate.apply(md)); @@ -146,7 +146,7 @@ public class LocationPredicateTest { * are ok. */ public void testReturnFalseWhenISpecifyALocationWhichIsNotAGrandChildOfInput() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(host)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(host)); Hardware md = new HardwareBuilder().id("foo").location(otherRegion).build(); assertFalse(predicate.apply(md)); } @@ -157,7 +157,7 @@ public class LocationPredicateTest { */ @Test(expectedExceptions = IllegalStateException.class) public void testThrowIllegalStateExceptionWhenInputIsAnOrphanedRegion() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(region)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(region)); Hardware md = new HardwareBuilder().id("foo").location(orphanedRegion).build(); predicate.apply(md); } @@ -168,7 +168,7 @@ public class LocationPredicateTest { */ @Test(expectedExceptions = IllegalStateException.class) public void testThrowIllegalStateExceptionWhenInputIsAnOrphanedZone() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(region)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(region)); Hardware md = new HardwareBuilder().id("foo").location(orphanedZone).build(); predicate.apply(md); } @@ -179,7 +179,7 @@ public class LocationPredicateTest { */ @Test(expectedExceptions = IllegalArgumentException.class) public void testThrowIllegalArgumentExceptionWhenWhenISpecifyAnOrphanedRegion() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(orphanedRegion)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(orphanedRegion)); Hardware md = new HardwareBuilder().id("foo").location(region).build(); predicate.apply(md); } @@ -190,7 +190,7 @@ public class LocationPredicateTest { */ @Test(expectedExceptions = IllegalArgumentException.class) public void testThrowIllegalArgumentExceptionWhenWhenISpecifyAnOrphanedZone() { - LocationPredicate predicate = new LocationPredicate(Suppliers.ofInstance(orphanedZone)); + NullEqualToIsParentOrIsGrandparentOfCurrentLocation predicate = new NullEqualToIsParentOrIsGrandparentOfCurrentLocation(Suppliers.ofInstance(orphanedZone)); Hardware md = new HardwareBuilder().id("foo").location(region).build(); predicate.apply(md); } diff --git a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java index 3ad50a7b4f..992e49f9e5 100644 --- a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java +++ b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java @@ -653,7 +653,7 @@ public class TemplateBuilderImplTest { assert false; } catch (NoSuchElementException e) { // make sure big data is not in the exception message - assertEquals(e.getMessage(), "no image matched predicate: And(equalsParentOrGrandparentOfCurrentLocation(),imageDescription(description))"); + assertEquals(e.getMessage(), "no image matched predicate: And(nullEqualToIsParentOrIsGrandparentOfCurrentLocation(),imageDescription(description))"); } verify(defaultOptions);