Search in sources :

Example 1 with AapProductEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class AapProductMapperTest method testAapProductMapper.

@Test
public void testAapProductMapper() {
    AAPProduct aapProduct = MapperUtil.getAapProduct();
    AapProductEntity aapProductEntity = AapProductMapper.INSTANCE.mapToAapProductEntity(aapProduct);
    assertEquals(aapProduct.getPackagingTypeCode().getValue(), aapProductEntity.getPackagingTypeCode());
    assertEquals(aapProduct.getPackagingTypeCode().getListID(), aapProductEntity.getPackagingTypeCodeListId());
    assertNull(aapProductEntity.getAapProcess());
    assertEquals(aapProduct.getPackagingUnitAverageWeightMeasure().getValue().doubleValue(), aapProductEntity.getPackagingUnitAvarageWeight());
    assertEquals(aapProduct.getPackagingUnitAverageWeightMeasure().getUnitCode(), aapProductEntity.getPackagingWeightUnitCode());
    assertEquals(aapProduct.getPackagingUnitAverageWeightMeasure().getValue().intValue(), aapProductEntity.getCalculatedPackagingWeight().intValue());
    assertEquals(aapProduct.getPackagingUnitQuantity().getValue().doubleValue(), aapProductEntity.getPackagingUnitCount());
    assertEquals(aapProduct.getPackagingUnitQuantity().getUnitCode(), aapProductEntity.getPackagingUnitCountCode());
    assertEquals(aapProduct.getSpeciesCode().getValue(), aapProductEntity.getSpeciesCode());
    assertEquals(aapProduct.getSpeciesCode().getListID(), aapProductEntity.getSpeciesCodeListId());
    assertEquals(aapProduct.getUnitQuantity().getValue().intValue(), aapProductEntity.getUnitQuantity().intValue());
    assertEquals(aapProduct.getUnitQuantity().getUnitCode(), aapProductEntity.getUnitQuantityCode());
    assertEquals(aapProduct.getWeightMeasure().getValue().intValue(), aapProductEntity.getWeightMeasure().intValue());
    assertEquals(aapProduct.getWeightMeasure().getUnitCode(), aapProductEntity.getWeightMeasureUnitCode());
    assertEquals(aapProduct.getWeightMeasure().getValue().intValue(), aapProductEntity.getCalculatedWeightMeasure().intValue());
    assertEquals(aapProduct.getWeighingMeansCode().getValue(), aapProductEntity.getWeighingMeansCode());
    assertEquals(aapProduct.getWeighingMeansCode().getListID(), aapProductEntity.getWeighingMeansCodeListId());
    assertEquals(aapProduct.getUsageCode().getValue(), aapProductEntity.getUsageCode());
    assertEquals(aapProduct.getUsageCode().getListID(), aapProductEntity.getUsageCodeListId());
}
Also used : AAPProduct(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) Test(org.junit.Test)

Example 2 with AapProductEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class AapProductMapperTest method testMapToProcessingProduct.

@Test
public void testMapToProcessingProduct() {
    // Prepare
    FACatch faCatch = MapperUtil.getFaCatch();
    FaCatchEntity faCatchEntity = new FaCatchEntity();
    FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
    AAPProcess aapProcess = MapperUtil.getAapProcess();
    AapProcessEntity aapProcessEntity = AapProcessMapper.INSTANCE.mapToAapProcessEntity(aapProcess);
    aapProcessEntity.setFaCatch(faCatchEntity);
    AAPProduct aapProduct = MapperUtil.getAapProduct();
    AapProductEntity aapProductEntity = AapProductMapper.INSTANCE.mapToAapProductEntity(aapProduct);
    aapProductEntity.setAapProcess(aapProcessEntity);
    // Create Input data
    ProcessingProductsDto processingProductsDto = AapProductMapper.INSTANCE.mapToProcessingProduct(aapProductEntity);
    assertEquals(processingProductsDto.getType(), faCatchEntity.getTypeCode());
    assertEquals(processingProductsDto.getGear(), faCatchEntity.getGearTypeCode());
    assertEquals(processingProductsDto.getSpecies(), faCatchEntity.getSpeciesCode());
    assertNull(processingProductsDto.getPreservation());
    assertNull(processingProductsDto.getPresentation());
    assertNull(processingProductsDto.getFreshness());
    assertEquals(processingProductsDto.getConversionFactor(), aapProcessEntity.getConversionFactor().doubleValue());
    assertEquals(processingProductsDto.getWeight(), aapProductEntity.getCalculatedWeightMeasure());
    assertEquals(processingProductsDto.getQuantity(), aapProductEntity.getUnitQuantity());
    assertEquals(processingProductsDto.getPackageWeight(), aapProductEntity.getPackagingUnitAvarageWeight());
    assertEquals(processingProductsDto.getPackageQuantity().doubleValue(), aapProductEntity.getPackagingUnitCount().doubleValue());
    assertEquals(processingProductsDto.getPackagingType(), aapProductEntity.getPackagingTypeCode());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AAPProduct(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct) AAPProcess(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess) ProcessingProductsDto(eu.europa.ec.fisheries.ers.service.dto.view.ProcessingProductsDto) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) FACatch(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) Test(org.junit.Test)

Example 3 with AapProductEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapperTest method testSpeciesCodeWithDuplicatedShouldFilterDuplicates.

@Test
public void testSpeciesCodeWithDuplicatedShouldFilterDuplicates() {
    FaCatchEntity faCatchEntity = new FaCatchEntity();
    faCatchEntity.setSpeciesCode("2222");
    AapProductEntity aapProductEntity = new AapProductEntity();
    aapProductEntity.setSpeciesCode("2222");
    AapProcessEntity aapProcessEntity = new AapProcessEntity();
    aapProcessEntity.setAapProducts(newSet(aapProductEntity));
    faCatchEntity.setAapProcesses(newSet(aapProcessEntity));
    FishingActivityEntity fa = FishingActivityEntity.builder().build();
    fa.setFaCatchs(newSet(faCatchEntity));
    List<String> speciesCode = FishingActivityMapper.INSTANCE.getSpeciesCode(fa);
    assertEquals(1, speciesCode.size());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 4 with AapProductEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class AapProcessMapper method getAapProductEntities.

protected Set<AapProductEntity> getAapProductEntities(List<AAPProduct> aapProducts, AapProcessEntity aapProcessEntity) {
    if (aapProducts == null || aapProducts.isEmpty()) {
        return Collections.emptySet();
    }
    Set<AapProductEntity> aapProductEntities = new HashSet<>();
    for (AAPProduct aapProduct : aapProducts) {
        AapProductEntity aapProductEntity = AapProductMapper.INSTANCE.mapToAapProductEntity(aapProduct);
        aapProductEntity.setAapProcess(aapProcessEntity);
        aapProductEntities.add(aapProductEntity);
    }
    return aapProductEntities;
}
Also used : AAPProduct(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) HashSet(java.util.HashSet)

Example 5 with AapProductEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class AapProcessMapperTest method testAapProcessMapper.

@Test
public void testAapProcessMapper() {
    AAPProcess aapProcess = MapperUtil.getAapProcess();
    AapProcessEntity aapProcessEntity = AapProcessMapper.INSTANCE.mapToAapProcessEntity(aapProcess);
    AapProcessCodeEntity entity = aapProcessEntity.getAapProcessCode().iterator().next();
    assertEquals(aapProcess.getTypeCodes().get(0).getValue(), entity.getTypeCode());
    assertEquals(aapProcess.getTypeCodes().get(0).getListID(), entity.getTypeCodeListId());
    assertEquals(aapProcess.getConversionFactorNumeric().getValue().intValue(), aapProcessEntity.getConversionFactor().intValue());
    assertNull(aapProcessEntity.getFaCatch());
    assertNotNull(aapProcessEntity.getAapProducts());
    AapProductEntity aapProductEntity = aapProcessEntity.getAapProducts().iterator().next();
    assertNotNull(aapProductEntity);
    aapProductEntity.getAapProcess().getAapProcessCode().iterator().next();
    assertEquals(aapProcess.getTypeCodes().get(0).getValue(), entity.getTypeCode());
}
Also used : AAPProcess(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess) AapProcessCodeEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessCodeEntity) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) Test(org.junit.Test)

Aggregations

AapProductEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity)5 Test (org.junit.Test)4 AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)3 AAPProduct (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct)3 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)2 AAPProcess (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess)2 AapProcessCodeEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessCodeEntity)1 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 ProcessingProductsDto (eu.europa.ec.fisheries.ers.service.dto.view.ProcessingProductsDto)1 HashSet (java.util.HashSet)1 FACatch (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch)1