@Test public void testResolvesDefaultName() throws Exception { Location location = resolve("localhost"); assertTrue(location instanceof LocalhostMachineProvisioningLocation); assertEquals(location.getDisplayName(), "localhost"); Location location2 = resolve("localhost()"); assertTrue(location2 instanceof LocalhostMachineProvisioningLocation); assertEquals(location2.getDisplayName(), "localhost"); }
@Test public void testResolvesPropertiesInSpec() throws Exception { Location location = resolve("localhost(privateKeyFile=myprivatekeyfile,name=myname)"); assertTrue(location instanceof LocalhostMachineProvisioningLocation); assertEquals(location.getDisplayName(), "myname"); assertEquals(location.getAllConfig(true).get("privateKeyFile"), "myprivatekeyfile"); }
public static BasicLocationMemento.Builder newLocationMementoBuilder(Location location) { BasicLocationMemento.Builder builder = BasicLocationMemento.builder(); Set<String> nonPersistableFlagNames = MutableMap.<String, Object>builder() .putAll(FlagUtils.getFieldsWithFlagsWithModifiers(location, Modifier.TRANSIENT)) .putAll(FlagUtils.getFieldsWithFlagsWithModifiers(location, Modifier.STATIC)) .put("id", String.class) .filterValues(Predicates.not(Predicates.instanceOf(ConfigKey.class))) .build() .keySet(); Map<String, Object> persistableFlags = MutableMap.<String, Object>builder() .putAll( FlagUtils.getFieldsWithFlagsExcludingModifiers( location, Modifier.STATIC ^ Modifier.TRANSIENT)) .removeAll(nonPersistableFlagNames) .build(); ConfigBag persistableConfig = new ConfigBag() .copy(((AbstractLocation) location).getLocalConfigBag()) .removeAll(nonPersistableFlagNames); builder.type = location.getClass().getName(); builder.typeClass = location.getClass(); builder.id = location.getId(); builder.displayName = location.getDisplayName(); builder.copyConfig(persistableConfig); builder.locationConfig.putAll(persistableFlags); Location parentLocation = location.getParent(); builder.parent = (parentLocation != null) ? parentLocation.getId() : null; for (Location child : location.getChildren()) { builder.children.add(child.getId()); } return builder; }
@Test public void testWithOldStyleColon() throws Exception { Location location = resolve("localhost:(name=myname)"); assertTrue(location instanceof LocalhostMachineProvisioningLocation); assertEquals(location.getDisplayName(), "myname"); }