示例#1
0
 public Product() {
   ProductUtils.initializeFieldsWithDefaultValues(
       this, String.class, Product.INVALID_STRING_VALUE);
 }
  /** Test of analyze method, of class NutrientComparisonAnalysis. */
  @Test
  public void testAnalyze() {
    MeanDeviationBasedNutrientComparisonAnalysis analysis =
        new MeanDeviationBasedNutrientComparisonAnalysis(measures);

    ArticleDescription desc = new ArticleDescription();
    GPCEntity gpc = new GPCEntity();
    gpc.setClazz("50131900");
    gpc.setBrick("10000168");
    desc.setClassificationCategoryCode(gpc);

    IngredientsAndAllergens ingredients = new IngredientsAndAllergens();
    EnergyNutrientsVitamins energyNutrients = new EnergyNutrientsVitamins();
    /* First test: kcal value is too high */
    // fill in data needed for analysis
    energyNutrients.setCalorificValueKcal(10000);
    energyNutrients.setCalorificValueKj(770);
    energyNutrients.setCalorificValueMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    energyNutrients.setNutritionalValueReference(100);
    energyNutrients.setNutritionalValueReferenceUnit(GR);

    List<NutritionalContentItem> nutrients = new ArrayList<>();
    NutritionalContentItem fat = new NutritionalContentItem();
    fat.setNutritionalContent(NutritionalContentCode.FAT);
    fat.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    fat.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    fat.setNutritionalContentQuantityContained(10);
    nutrients.add(fat);

    NutritionalContentItem fasat = new NutritionalContentItem();
    fasat.setNutritionalContent(NutritionalContentCode.FASAT);
    fasat.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    fasat.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    fasat.setNutritionalContentQuantityContained(2);
    nutrients.add(fasat);

    NutritionalContentItem carbs = new NutritionalContentItem();
    carbs.setNutritionalContent(NutritionalContentCode.CHOAVL);
    carbs.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    carbs.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    carbs.setNutritionalContentQuantityContained(2.5);
    nutrients.add(carbs);

    NutritionalContentItem sugar = new NutritionalContentItem();
    sugar.setNutritionalContent(NutritionalContentCode.SUGAR);
    sugar.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    sugar.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    sugar.setNutritionalContentQuantityContained(0.0);
    nutrients.add(sugar);

    NutritionalContentItem protein = new NutritionalContentItem();
    protein.setNutritionalContent(NutritionalContentCode.PRO);
    protein.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    protein.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    protein.setNutritionalContentQuantityContained(23);
    nutrients.add(protein);

    NutritionalContentItem salt = new NutritionalContentItem();
    salt.setNutritionalContent(NutritionalContentCode.SALTEQ);
    salt.setNutritionalContentMeasurementPrecision(MeasurementPrecisionCode.APPROXIMATELY);
    salt.setNutritionalContentQuantityContain(ServingSizeUnitOfMeasureCode.GR);
    salt.setNutritionalContentQuantityContained(16);
    nutrients.add(salt);

    energyNutrients.setNutrients(nutrients);
    ingredients.setEnergyNutrientsVitamins(Arrays.asList(energyNutrients));

    Product product = ProductUtils.createProduct(desc, ingredients);
    boolean expResult = false;
    boolean result = analysis.analyze(product);
    assertEquals(expResult, result);
  }
 public AllergyItem() {
   ProductUtils.initializeEnumFieldsWithDefaultValue(this);
   setId(UUIDUtils.create());
 }