ScaffoldingImpl implements Scaffolding { protected String buildFlowFromDefaultFlow(Map<String, String> customTokens, boolean supportsEntityServicesMapping) throws IOException { String flowSrcFile = "scaffolding/defaultFlow.flow.json"; String fileContents = null; try (InputStream inputStream = ScaffoldingImpl.class.getClassLoader().getResourceAsStream(flowSrcFile)) { assert inputStream != null; fileContents = IOUtils.toString(inputStream); for (String key : customTokens.keySet()) { String value = customTokens.get(key); if (value != null) { fileContents = fileContents.replace(key, value); } } } if (!supportsEntityServicesMapping) { fileContents = fileContents.replaceAll("entity-services-mapping", "default-mapping"); } return fileContents; }  static String getAbsolutePath(String first, String... more); @Override Path getLegacyFlowDir(String entityName, String flowName, FlowType flowType); @Override void createEntity(String entityName); @Override void createLegacyMappingDir(String mappingName); @Override void createMappingDir(String mappingName); @Override void createCustomModule(String stepName, String stepType); @Override void createCustomModule(String stepName, String stepType, String format); @Override void createDefaultFlow(String flowName); @Override void createLegacyFlow(String entityName, String flowName,
                                           FlowType flowType, CodeFormat codeFormat,
                                           DataFormat dataFormat); @Override void createLegacyFlow(String entityName, String flowName,
                                           FlowType flowType, CodeFormat codeFormat,
                                           DataFormat dataFormat, boolean useEsModel); @Override void createLegacyFlow(String entityName, String flowName,
                                           FlowType flowType, CodeFormat codeFormat,
                                           DataFormat dataFormat, boolean useEsModel, String mappingNameWithVersion); @Override void updateLegacyEntity(String entityName); @Override void createRestExtension(String entityName, String extensionName,
                                              FlowType flowType, CodeFormat codeFormat); @Override void createRestTransform(String entityName, String transformName,
                                              FlowType flowType, CodeFormat codeFormat);  }
@Test public void buildFlowFromDefaultFlow() throws Exception { String flow = new ScaffoldingImpl().buildFlowFromDefaultFlow(customTokens, true); JsonNode json = new ObjectMapper().readTree(flow); assertEquals("my-flow", json.get("name").asText()); JsonNode stepTwo = json.get("steps").get("2"); assertEquals("entity-services-mapping", stepTwo.get("stepDefinitionName").asText()); JsonNode mappingOptions = stepTwo.get("options"); assertEquals("my-staging", mappingOptions.get("sourceDatabase").asText()); assertEquals("my-final", mappingOptions.get("targetDatabase").asText()); assertEquals(false, mappingOptions.get("validateEntity").asBoolean(), "Per DHFPROD-2811, we now want to scaffold out a mapping step with " + "validateEntity:false. That way, entity validation is not turned on, but a " + "user can see that the feature is available."); }
@Test public void buildFlowWhenNotSupportingEntityServicesMapping() throws Exception { String flow = new ScaffoldingImpl().buildFlowFromDefaultFlow(customTokens, false); JsonNode json = new ObjectMapper().readTree(flow); JsonNode stepTwo = json.get("steps").get("2"); assertEquals("default-mapping", stepTwo.get("stepDefinitionName").asText(), "When ES mapping is not supported, the mapping step should use the 'default-mapping' step definition"); }