OpenstackIaasHandler extends AbstractThreadedTargetHandler { static String findStorageProperty( Map<String,String> targetProperties, String storageId, String propertyPrefix ) { String property = propertyPrefix + storageId; String value = targetProperties.get( property ); return Utils.isEmptyOrWhitespaces( value ) ? DEFAULTS.get( propertyPrefix ) : value.trim(); }  @Override String getTargetId(); @Override String createMachine( TargetHandlerParameters parameters ); @Override boolean isMachineRunning( TargetHandlerParameters parameters, String machineId ); @Override MachineConfigurator machineConfigurator( TargetHandlerParameters parameters, String machineId ); @Override void terminateMachine( TargetHandlerParameters parameters, String machineId ); @Override String retrievePublicIpAddress( TargetHandlerParameters parameters, String machineId ); static final String TARGET_ID; }
@Test public void testFindStorageProperty() { Map<String,String> targetProperties = new HashMap<>(); String s = findStorageProperty( targetProperties, "a", VOLUME_NAME_PREFIX ); Assert.assertEquals( DEFAULTS.get( VOLUME_NAME_PREFIX ), s ); Assert.assertNotNull( DEFAULTS.get( VOLUME_NAME_PREFIX )); targetProperties.put( VOLUME_NAME_PREFIX + "a", "" ); s = findStorageProperty( targetProperties, "a", VOLUME_NAME_PREFIX ); Assert.assertEquals( DEFAULTS.get( VOLUME_NAME_PREFIX ), s ); targetProperties.put( VOLUME_NAME_PREFIX + "a", "name" ); s = findStorageProperty( targetProperties, "a", VOLUME_NAME_PREFIX ); Assert.assertEquals( "name", s ); targetProperties.put( VOLUME_NAME_PREFIX + "a", "name with space after " ); s = findStorageProperty( targetProperties, "a", VOLUME_NAME_PREFIX ); Assert.assertEquals( "name with space after", s ); }