private EntityType createCategoricalRefEntityType(String entityName) {
   EntityType targetRefEntityType = entityTypeFactory.create(entityName);
   Attribute targetCodeAttribute = attrMetaFactory.create().setName("code").setDataType(INT);
   Attribute targetLabelAttribute = attrMetaFactory.create().setName("label");
   targetRefEntityType.addAttribute(targetCodeAttribute, ROLE_ID);
   targetRefEntityType.addAttribute(targetLabelAttribute, ROLE_LABEL);
   return targetRefEntityType;
 }
  @BeforeMethod
  public void init() {
    dataService = Mockito.mock(DataService.class);

    categoryAlgorithmGenerator = new OneToOneCategoryAlgorithmGenerator(dataService);

    EntityType targetRefEntityType = createCategoricalRefEntityType("POTATO_REF");
    Entity targetEntity1 =
        new DynamicEntity(targetRefEntityType, of("code", 1, "label", "Almost daily + daily"));
    Entity targetEntity2 =
        new DynamicEntity(targetRefEntityType, of("code", 2, "label", "Several times a week"));
    Entity targetEntity3 =
        new DynamicEntity(targetRefEntityType, of("code", 3, "label", "About once a week"));
    Entity targetEntity4 =
        new DynamicEntity(
            targetRefEntityType, of("code", 4, "label", "Never + fewer than once a week"));
    Entity targetEntity5 =
        new DynamicEntity(targetRefEntityType, of("code", 9, "label", "missing"));

    targetAttribute =
        attrMetaFactory
            .create()
            .setName("Current Consumption Frequency of Potatoes")
            .setDataType(CATEGORICAL);
    targetAttribute.setRefEntity(targetRefEntityType);

    Mockito.when(dataService.findAll(targetRefEntityType.getName()))
        .thenReturn(
            Stream.of(targetEntity1, targetEntity2, targetEntity3, targetEntity4, targetEntity5));

    targetEntityType = entityTypeFactory.create("target");
    targetEntityType.addAttribute(targetAttribute);

    EntityType sourceRefEntityType = createCategoricalRefEntityType("LifeLines_POTATO_REF");
    Entity sourceEntity1 =
        new DynamicEntity(targetRefEntityType, of("code", 1, "label", "Not this month"));
    Entity sourceEntity2 =
        new DynamicEntity(targetRefEntityType, of("code", 2, "label", "1 day per month"));
    Entity sourceEntity3 =
        new DynamicEntity(targetRefEntityType, of("code", 3, "label", "2-3 days per month"));
    Entity sourceEntity4 =
        new DynamicEntity(targetRefEntityType, of("code", 4, "label", "1 day per week"));
    Entity sourceEntity5 =
        new DynamicEntity(targetRefEntityType, of("code", 5, "label", "2-3 days per week"));
    Entity sourceEntity6 =
        new DynamicEntity(targetRefEntityType, of("code", 6, "label", "4-5 days per week"));
    Entity sourceEntity7 =
        new DynamicEntity(targetRefEntityType, of("code", 7, "label", "6-7 days per week"));
    Entity sourceEntity8 =
        new DynamicEntity(targetRefEntityType, of("code", 8, "label", "9 days per week"));

    sourceAttribute = attrMetaFactory.create().setName("MESHED_POTATO").setDataType(CATEGORICAL);
    sourceAttribute.setLabel(
        "How often did you eat boiled or mashed potatoes (also in stew) in the past month? Baked potatoes are asked later");
    sourceAttribute.setRefEntity(sourceRefEntityType);

    Mockito.when(dataService.findAll(sourceRefEntityType.getName()))
        .thenReturn(
            Stream.of(
                sourceEntity1,
                sourceEntity2,
                sourceEntity3,
                sourceEntity4,
                sourceEntity5,
                sourceEntity6,
                sourceEntity7,
                sourceEntity8));

    sourceEntityType = entityTypeFactory.create("source");
    sourceEntityType.addAttributes(Lists.newArrayList(sourceAttribute));
  }