mirror of https://github.com/apache/jclouds.git
add predicates and template builder live tests for location scopes SYSTEM and NETWORK
This commit is contained in:
parent
486be5acc4
commit
c684a59cb3
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue