add predicates and template builder live tests for location scopes SYSTEM and NETWORK

This commit is contained in:
Dies Koper 2012-08-06 23:26:59 +10:00
parent 486be5acc4
commit c684a59cb3
2 changed files with 50 additions and 0 deletions

View File

@ -205,6 +205,22 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|| location.getParent().getIso3166Codes().containsAll(location.getIso3166Codes()) : location + " ||" || location.getParent().getIso3166Codes().containsAll(location.getIso3166Codes()) : location + " ||"
+ location.getParent(); + location.getParent();
break; break;
case SYSTEM:
Location systemParent = location.getParent();
// loop up to root, which must be the provider
while (systemParent.getParent() != null) {
systemParent = systemParent.getParent();
}
assertProvider(systemParent);
break;
case NETWORK:
Location networkParent = location.getParent();
// loop up to root, which must be the provider
while (networkParent.getParent() != null) {
networkParent = networkParent.getParent();
}
assertProvider(networkParent);
break;
case HOST: case HOST:
Location provider2 = location.getParent().getParent().getParent(); Location provider2 = location.getParent().getParent().getParent();
// zone can be a direct descendant of provider // zone can be a direct descendant of provider

View File

@ -86,6 +86,40 @@ public class LocationPredicates {
} }
} }
public static Predicate<Location> isSystem() {
return IsSystem.INSTANCE;
}
static enum IsSystem implements Predicate<Location> {
INSTANCE;
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.SYSTEM;
}
@Override
public String toString() {
return "isSystem()";
}
}
public static Predicate<Location> isNetwork() {
return IsNetwork.INSTANCE;
}
static enum IsNetwork implements Predicate<Location> {
INSTANCE;
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.NETWORK;
}
@Override
public String toString() {
return "isNetwork()";
}
}
public static Predicate<Location> idEquals(String id) { public static Predicate<Location> idEquals(String id) {
return new IdEquals(id); return new IdEquals(id);
} }