DockerAndScriptUtils { public static Map<String,String> buildReferenceMap( Instance instance ) { Map<String,String> result = new HashMap<> (); String instancePath = InstanceHelpers.computeInstancePath( instance ); result.put( ROBOCONF_INSTANCE_NAME, instance.getName()); result.put( ROBOCONF_INSTANCE_PATH, instancePath ); result.put( ROBOCONF_COMPONENT_NAME, instance.getComponent().getName()); result.put( ROBOCONF_CLEAN_INSTANCE_PATH, cleanInstancePath( instancePath )); result.put( ROBOCONF_CLEAN_REVERSED_INSTANCE_PATH, cleanReversedInstancePath( instancePath )); return result; } private  DockerAndScriptUtils(); static Map<String,String> buildReferenceMap( Instance instance ); static String cleanInstancePath( String instancePath ); static String cleanReversedInstancePath( String instancePath ); static final String ROBOCONF_INSTANCE_NAME; static final String ROBOCONF_INSTANCE_PATH; static final String ROBOCONF_CLEAN_INSTANCE_PATH; static final String ROBOCONF_CLEAN_REVERSED_INSTANCE_PATH; static final String ROBOCONF_COMPONENT_NAME; }
@Test public void testBuildReferenceMap() { TestApplication app = new TestApplication(); Map<String,String> map = DockerAndScriptUtils.buildReferenceMap( app.getMySqlVm()); Assert.assertEquals( 5, map.size()); Assert.assertEquals( app.getMySqlVm().getName(), map.get( DockerAndScriptUtils.ROBOCONF_INSTANCE_NAME )); Assert.assertEquals( "/" + app.getMySqlVm().getName(), map.get( DockerAndScriptUtils.ROBOCONF_INSTANCE_PATH )); Assert.assertEquals( app.getMySqlVm().getComponent().getName(), map.get( DockerAndScriptUtils.ROBOCONF_COMPONENT_NAME )); Assert.assertEquals( "mysql_vm", map.get( DockerAndScriptUtils.ROBOCONF_CLEAN_INSTANCE_PATH )); Assert.assertEquals( "mysql_vm", map.get( DockerAndScriptUtils.ROBOCONF_CLEAN_REVERSED_INSTANCE_PATH )); map = DockerAndScriptUtils.buildReferenceMap( app.getWar()); Assert.assertEquals( 5, map.size()); Assert.assertEquals( app.getWar().getName(), map.get( DockerAndScriptUtils.ROBOCONF_INSTANCE_NAME )); Assert.assertEquals( "/tomcat-vm/tomcat-server/hello-world", map.get( DockerAndScriptUtils.ROBOCONF_INSTANCE_PATH )); Assert.assertEquals( app.getWar().getComponent().getName(), map.get( DockerAndScriptUtils.ROBOCONF_COMPONENT_NAME )); Assert.assertEquals( "tomcat_vm_tomcat_server_hello_world", map.get( DockerAndScriptUtils.ROBOCONF_CLEAN_INSTANCE_PATH )); Assert.assertEquals( "hello_world_tomcat_server_tomcat_vm", map.get( DockerAndScriptUtils.ROBOCONF_CLEAN_REVERSED_INSTANCE_PATH )); }