@Test public void testConversionNormal() { Network network = new Network(); network.setAttributes(new Json(NETWORK_ATTRIBUTES)); dbStack.setNetwork(network); DatabaseServer server = new DatabaseServer(); server.setName("myserver"); server.setInstanceType("db.m3.medium"); server.setDatabaseVendor(DatabaseVendor.POSTGRES); server.setConnectionDriver("org.postgresql.Driver"); server.setRootUserName("root"); server.setRootPassword("cloudera"); server.setStorageSize(50L); SecurityGroup securityGroup = new SecurityGroup(); Set<String> securityGroupIds = new HashSet<>(); securityGroupIds.add("sg-1234"); securityGroup.setSecurityGroupIds(securityGroupIds); server.setSecurityGroup(securityGroup); server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES)); dbStack.setDatabaseServer(server); dbStack.setTags(new Json(STACK_TAGS)); dbStack.setTemplate("template"); DatabaseStack convertedStack = underTest.convert(dbStack); assertEquals(1, convertedStack.getNetwork().getParameters().size()); assertEquals("bar", convertedStack.getNetwork().getParameters().get("foo")); assertEquals("myserver", convertedStack.getDatabaseServer().getServerId()); assertEquals("db.m3.medium", convertedStack.getDatabaseServer().getFlavor()); assertEquals(DatabaseEngine.POSTGRESQL, convertedStack.getDatabaseServer().getEngine()); assertEquals("org.postgresql.Driver", convertedStack.getDatabaseServer().getConnectionDriver()); assertEquals("root", convertedStack.getDatabaseServer().getRootUserName()); assertEquals("cloudera", convertedStack.getDatabaseServer().getRootPassword()); assertEquals(50L, convertedStack.getDatabaseServer().getStorageSize().longValue()); assertEquals(List.of("sg-1234"), convertedStack.getDatabaseServer().getSecurity().getCloudSecurityIds()); assertEquals(2, convertedStack.getDatabaseServer().getParameters().size()); assertEquals("that", convertedStack.getDatabaseServer().getParameters().get("this")); assertEquals("template", convertedStack.getTemplate()); Map<String, String> tags = convertedStack.getTags(); assertEquals(3, tags.size()); assertEquals("uvalue1", tags.get("ukey1")); assertEquals("dvalue1", tags.get("dkey1")); assertEquals("value1", tags.get("key1")); }
public DatabaseStack convert(DBStack dbStack) { Network network = buildNetwork(dbStack); DatabaseServer databaseServer = buildDatabaseServer(dbStack); return new DatabaseStack(network, databaseServer, getUserDefinedTags(dbStack), dbStack.getTemplate()); }
DBStackToDatabaseStackConverter { public DatabaseStack convert(DBStack dbStack) { Network network = buildNetwork(dbStack); DatabaseServer databaseServer = buildDatabaseServer(dbStack); return new DatabaseStack(network, databaseServer, getUserDefinedTags(dbStack), dbStack.getTemplate()); } }
DBStackToDatabaseStackConverter { public DatabaseStack convert(DBStack dbStack) { Network network = buildNetwork(dbStack); DatabaseServer databaseServer = buildDatabaseServer(dbStack); return new DatabaseStack(network, databaseServer, getUserDefinedTags(dbStack), dbStack.getTemplate()); }  }
DBStackToDatabaseStackConverter { public DatabaseStack convert(DBStack dbStack) { Network network = buildNetwork(dbStack); DatabaseServer databaseServer = buildDatabaseServer(dbStack); return new DatabaseStack(network, databaseServer, getUserDefinedTags(dbStack), dbStack.getTemplate()); }  DatabaseStack convert(DBStack dbStack); }
DBStackToDatabaseStackConverter { public DatabaseStack convert(DBStack dbStack) { Network network = buildNetwork(dbStack); DatabaseServer databaseServer = buildDatabaseServer(dbStack); return new DatabaseStack(network, databaseServer, getUserDefinedTags(dbStack), dbStack.getTemplate()); }  DatabaseStack convert(DBStack dbStack);  }