@Test void testGenerate() { String expected = "var SUM_WEIGHT;\nif($('MESHED_POTATO').isNull().value() && $('MESHED_POTATO_1').isNull().value()){\n\tSUM_WEIGHT = new newValue();\n\tSUM_WEIGHT.value();\n}else{\n\tSUM_WEIGHT = new newValue(0);\n\tSUM_WEIGHT.plus($('MESHED_POTATO').map({\"1\":0,\"2\":0.2,\"3\":0.6,\"4\":1,\"5\":2.5,\"6\":4.5,\"7\":6.5}, null, null).value());\n\tSUM_WEIGHT.plus($('MESHED_POTATO_1').map({\"1\":0.1,\"2\":0.5,\"3\":1,\"4\":3,\"5\":5.5,\"6\":7,\"7\":17.5,\"8\":31.5,\"9\":42}, null, null).value());\n\tSUM_WEIGHT.group([0,1,3,6,7]).map({\"-0\":\"4\",\"0-1\":\"4\",\"1-3\":\"3\",\"3-6\":\"2\",\"6-7\":\"1\",\"7+\":\"1\"}, null, null).value();\n}"; String generateMultipleAttributes = categoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute, sourceAttribute1), targetEntityType, sourceEntityType); assertEquals(expected, generateMultipleAttributes); }
@Override public String generate( Attribute targetAttribute, List<Attribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { StringBuilder stringBuilder = new StringBuilder(); if (suitableForGeneratingWeightedMap(targetAttribute, sourceAttributes)) { stringBuilder .append(createAlgorithmNullCheckIfStatement(sourceAttributes)) .append(createAlgorithmElseBlock(targetAttribute, sourceAttributes)); } else { for (Attribute sourceAttribute : sourceAttributes) { stringBuilder.append( oneToOneCategoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType)); } } return stringBuilder.toString(); }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { @Override public String generate( Attribute targetAttribute, List<Attribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { StringBuilder stringBuilder = new StringBuilder(); if (suitableForGeneratingWeightedMap(targetAttribute, sourceAttributes)) { stringBuilder .append(createAlgorithmNullCheckIfStatement(sourceAttributes)) .append(createAlgorithmElseBlock(targetAttribute, sourceAttributes)); } else { for (Attribute sourceAttribute : sourceAttributes) { stringBuilder.append( oneToOneCategoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType)); } } return stringBuilder.toString(); } }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { @Override public String generate( Attribute targetAttribute, List<Attribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { StringBuilder stringBuilder = new StringBuilder(); if (suitableForGeneratingWeightedMap(targetAttribute, sourceAttributes)) { stringBuilder .append(createAlgorithmNullCheckIfStatement(sourceAttributes)) .append(createAlgorithmElseBlock(targetAttribute, sourceAttributes)); } else { for (Attribute sourceAttribute : sourceAttributes) { stringBuilder.append( oneToOneCategoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType)); } } return stringBuilder.toString(); } OneToManyCategoryAlgorithmGenerator(DataService dataService); }
OneToManyCategoryAlgorithmGenerator extends AbstractCategoryAlgorithmGenerator { @Override public String generate( Attribute targetAttribute, List<Attribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { StringBuilder stringBuilder = new StringBuilder(); if (suitableForGeneratingWeightedMap(targetAttribute, sourceAttributes)) { stringBuilder .append(createAlgorithmNullCheckIfStatement(sourceAttributes)) .append(createAlgorithmElseBlock(targetAttribute, sourceAttributes)); } else { for (Attribute sourceAttribute : sourceAttributes) { stringBuilder.append( oneToOneCategoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType)); } } 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 { @Override public String generate( Attribute targetAttribute, List<Attribute> sourceAttributes, EntityType targetEntityType, EntityType sourceEntityType) { StringBuilder stringBuilder = new StringBuilder(); if (suitableForGeneratingWeightedMap(targetAttribute, sourceAttributes)) { stringBuilder .append(createAlgorithmNullCheckIfStatement(sourceAttributes)) .append(createAlgorithmElseBlock(targetAttribute, sourceAttributes)); } else { for (Attribute sourceAttribute : sourceAttributes) { stringBuilder.append( oneToOneCategoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute), targetEntityType, sourceEntityType)); } } 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);  }