@Test void testHeterogenousGenerator() { String expectedAlgorithm = "$('MESHED_POTATO_1').map({\"1\":\"4\",\"2\":\"4\",\"3\":\"3\",\"4\":\"2\",\"5\":\"2\",\"6\":\"1\",\"7\":\"1\",\"8\":\"1\",\"9\":\"1\"}, null, null).value();$('MESHED_POTATO').map({\"1\":\"4\",\"2\":\"4\",\"3\":\"4\",\"4\":\"3\",\"5\":\"2\",\"6\":\"2\",\"7\":\"1\"}, null, null).value();$('Stroke').map({\"1\":\"2\",\"2\":\"4\",\"9\":\"9\"}, null, null).value();"; String actual = categoryAlgorithmGenerator.generate( targetAttribute, Arrays.asList(sourceAttribute1, sourceAttribute, sourceAttribute2), targetEntityType, sourceEntityType); assertEquals(expectedAlgorithm, actual); }
@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);  }