@Test void testCreateAlgorithmNullCheck() { String actual = "var SUM_WEIGHT;\nif($('MESHED_POTATO_1').isNull().value() && $('MESHED_POTATO').isNull().value() && $('Stroke').isNull().value()){\n\tSUM_WEIGHT = new newValue();\n\tSUM_WEIGHT.value();\n}"; String createAlgorithmNullCheck = categoryAlgorithmGenerator.createAlgorithmNullCheckIfStatement( Arrays.asList(sourceAttribute1, sourceAttribute, sourceAttribute2)); assertEquals(actual, createAlgorithmNullCheck); }
String createAlgorithmNullCheckIfStatement(List<Attribute> sourceAttributes) { StringBuilder stringBuilder = new StringBuilder(); if (!sourceAttributes.isEmpty()) { stringBuilder.append("var SUM_WEIGHT;\n").append("if("); sourceAttributes.stream() .forEach( attribute -> stringBuilder .append("$('") .append(attribute.getName()) .append("').isNull().value() && ")); stringBuilder.delete(stringBuilder.length() - 4, stringBuilder.length()); stringBuilder .append("){\n") .append("\tSUM_WEIGHT = new newValue();\n") .append("\tSUM_WEIGHT.value();\n}"); } return stringBuilder.toString(); }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { String createAlgorithmNullCheckIfStatement(List<Attribute> sourceAttributes) { StringBuilder stringBuilder = new StringBuilder(); if (!sourceAttributes.isEmpty()) { stringBuilder.append("var SUM_WEIGHT;\n").append("if("); sourceAttributes.stream() .forEach( attribute -> stringBuilder .append("$('") .append(attribute.getName()) .append("').isNull().value() && ")); stringBuilder.delete(stringBuilder.length() - 4, stringBuilder.length()); stringBuilder .append("){\n") .append("\tSUM_WEIGHT = new newValue();\n") .append("\tSUM_WEIGHT.value();\n}"); } return stringBuilder.toString(); } }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { String createAlgorithmNullCheckIfStatement(List<Attribute> sourceAttributes) { StringBuilder stringBuilder = new StringBuilder(); if (!sourceAttributes.isEmpty()) { stringBuilder.append("var SUM_WEIGHT;\n").append("if("); sourceAttributes.stream() .forEach( attribute -> stringBuilder .append("$('") .append(attribute.getName()) .append("').isNull().value() && ")); stringBuilder.delete(stringBuilder.length() - 4, stringBuilder.length()); stringBuilder .append("){\n") .append("\tSUM_WEIGHT = new newValue();\n") .append("\tSUM_WEIGHT.value();\n}"); } return stringBuilder.toString(); } OneToManyCategoryAlgorithmGenerator(DataService dataService); }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { String createAlgorithmNullCheckIfStatement(List<Attribute> sourceAttributes) { StringBuilder stringBuilder = new StringBuilder(); if (!sourceAttributes.isEmpty()) { stringBuilder.append("var SUM_WEIGHT;\n").append("if("); sourceAttributes.stream() .forEach( attribute -> stringBuilder .append("$('") .append(attribute.getName()) .append("').isNull().value() && ")); stringBuilder.delete(stringBuilder.length() - 4, stringBuilder.length()); stringBuilder .append("){\n") .append("\tSUM_WEIGHT = new newValue();\n") .append("\tSUM_WEIGHT.value();\n}"); } return stringBuilder.toString(); } OneToManyCategoryAlgorithmGenerator(DataService dataService); @Override boolean isSuitable(Attribute targetAttribute, List<Attribute> sourceAttributes); @Override String generate(
      Attribute targetAttribute,
      List<Attribute> sourceAttributes,
      EntityType targetEntityType,
      EntityType sourceEntityType); String generateWeightedMap(Attribute attribute); String groupCategoryValues(Attribute attribute); }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { String createAlgorithmNullCheckIfStatement(List<Attribute> sourceAttributes) { StringBuilder stringBuilder = new StringBuilder(); if (!sourceAttributes.isEmpty()) { stringBuilder.append("var SUM_WEIGHT;\n").append("if("); sourceAttributes.stream() .forEach( attribute -> stringBuilder .append("$('") .append(attribute.getName()) .append("').isNull().value() && ")); stringBuilder.delete(stringBuilder.length() - 4, stringBuilder.length()); stringBuilder .append("){\n") .append("\tSUM_WEIGHT = new newValue();\n") .append("\tSUM_WEIGHT.value();\n}"); } return stringBuilder.toString(); } OneToManyCategoryAlgorithmGenerator(DataService dataService); @Override boolean isSuitable(Attribute targetAttribute, List<Attribute> sourceAttributes); @Override String generate(
      Attribute targetAttribute,
      List<Attribute> sourceAttributes,
      EntityType targetEntityType,
      EntityType sourceEntityType); String generateWeightedMap(Attribute attribute); String groupCategoryValues(Attribute attribute);  }