@Test public void testEmptyModel() { CreateNewMicroServiceModel model = new CreateNewMicroServiceModel("file.yml", "model", "desc", "1.0", "id"); assertNotNull(model); assertEquals(1, model.addValuesToNewModel(".yml").size()); }
public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); MsAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; if (!classMap.containsKey(this.newModel.getModelName())) { logger.error( "Model Provided does not contain the service name provided in request. Unable to import new model"); PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); if (mainClass.getSubClass() != null) { String value = new Gson().toJson(mainClass.getSubClass()); newModel.setSubAttributes(value); } if (mainClass.getAttribute() != null) { String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); int equalsIndexForAttributes = attributes.indexOf("="); String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } if (mainClass.getRefAttribute() != null) { String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); int equalsIndex = refAttributes.indexOf("="); String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRefAttributes(refAttributesAfterFirstEquals); } if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } if (mainClass.getRuleFormation() != null) { this.newModel.setRuleFormation(mainClass.getRuleFormation()); } if (mainClass.getDataOrderInfo() != null) { this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); } } else { String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); if (!dependency.isEmpty()) { for (String element : dependency) { MsAttributeObject temp = new MsAttributeObject(); if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSubAttributes(subAttribute); if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { this.newModel .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } successMap.put("success", "success"); return successMap; }
CreateNewMicroServiceModel { public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); MsAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; if (!classMap.containsKey(this.newModel.getModelName())) { logger.error( "Model Provided does not contain the service name provided in request. Unable to import new model"); PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); if (mainClass.getSubClass() != null) { String value = new Gson().toJson(mainClass.getSubClass()); newModel.setSubAttributes(value); } if (mainClass.getAttribute() != null) { String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); int equalsIndexForAttributes = attributes.indexOf("="); String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } if (mainClass.getRefAttribute() != null) { String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); int equalsIndex = refAttributes.indexOf("="); String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRefAttributes(refAttributesAfterFirstEquals); } if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } if (mainClass.getRuleFormation() != null) { this.newModel.setRuleFormation(mainClass.getRuleFormation()); } if (mainClass.getDataOrderInfo() != null) { this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); } } else { String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); if (!dependency.isEmpty()) { for (String element : dependency) { MsAttributeObject temp = new MsAttributeObject(); if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSubAttributes(subAttribute); if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { this.newModel .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } successMap.put("success", "success"); return successMap; } }
CreateNewMicroServiceModel { public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); MsAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; if (!classMap.containsKey(this.newModel.getModelName())) { logger.error( "Model Provided does not contain the service name provided in request. Unable to import new model"); PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); if (mainClass.getSubClass() != null) { String value = new Gson().toJson(mainClass.getSubClass()); newModel.setSubAttributes(value); } if (mainClass.getAttribute() != null) { String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); int equalsIndexForAttributes = attributes.indexOf("="); String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } if (mainClass.getRefAttribute() != null) { String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); int equalsIndex = refAttributes.indexOf("="); String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRefAttributes(refAttributesAfterFirstEquals); } if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } if (mainClass.getRuleFormation() != null) { this.newModel.setRuleFormation(mainClass.getRuleFormation()); } if (mainClass.getDataOrderInfo() != null) { this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); } } else { String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); if (!dependency.isEmpty()) { for (String element : dependency) { MsAttributeObject temp = new MsAttributeObject(); if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSubAttributes(subAttribute); if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { this.newModel .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } successMap.put("success", "success"); return successMap; } CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version);  CreateNewMicroServiceModel(String importFile, String modelName, String description, String version,
            String randomID); }
CreateNewMicroServiceModel { public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); MsAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; if (!classMap.containsKey(this.newModel.getModelName())) { logger.error( "Model Provided does not contain the service name provided in request. Unable to import new model"); PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); if (mainClass.getSubClass() != null) { String value = new Gson().toJson(mainClass.getSubClass()); newModel.setSubAttributes(value); } if (mainClass.getAttribute() != null) { String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); int equalsIndexForAttributes = attributes.indexOf("="); String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } if (mainClass.getRefAttribute() != null) { String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); int equalsIndex = refAttributes.indexOf("="); String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRefAttributes(refAttributesAfterFirstEquals); } if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } if (mainClass.getRuleFormation() != null) { this.newModel.setRuleFormation(mainClass.getRuleFormation()); } if (mainClass.getDataOrderInfo() != null) { this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); } } else { String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); if (!dependency.isEmpty()) { for (String element : dependency) { MsAttributeObject temp = new MsAttributeObject(); if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSubAttributes(subAttribute); if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { this.newModel .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } successMap.put("success", "success"); return successMap; } CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version);  CreateNewMicroServiceModel(String importFile, String modelName, String description, String version,
            String randomID); Map<String, String> addValuesToNewModel(String type); Map<String, String> saveImportService(); }
CreateNewMicroServiceModel { public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); MsAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; if (!classMap.containsKey(this.newModel.getModelName())) { logger.error( "Model Provided does not contain the service name provided in request. Unable to import new model"); PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); if (mainClass.getSubClass() != null) { String value = new Gson().toJson(mainClass.getSubClass()); newModel.setSubAttributes(value); } if (mainClass.getAttribute() != null) { String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); int equalsIndexForAttributes = attributes.indexOf("="); String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } if (mainClass.getRefAttribute() != null) { String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); int equalsIndex = refAttributes.indexOf("="); String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRefAttributes(refAttributesAfterFirstEquals); } if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } if (mainClass.getRuleFormation() != null) { this.newModel.setRuleFormation(mainClass.getRuleFormation()); } if (mainClass.getDataOrderInfo() != null) { this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); } } else { String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); if (!dependency.isEmpty()) { for (String element : dependency) { MsAttributeObject temp = new MsAttributeObject(); if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSubAttributes(subAttribute); if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { this.newModel .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } successMap.put("success", "success"); return successMap; } CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version);  CreateNewMicroServiceModel(String importFile, String modelName, String description, String version,
            String randomID); Map<String, String> addValuesToNewModel(String type); Map<String, String> saveImportService();  }