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());
}
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());
}
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());
}
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;
}
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());
}
Aggregations