use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity 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.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchMapperTest method testFaCatchMapper.
@Test
public void testFaCatchMapper() {
FACatch faCatch = MapperUtil.getFaCatch();
FaCatchEntity faCatchEntity = FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
assertFaCatchFields(faCatch, faCatchEntity);
assertNull(faCatchEntity.getFishingActivity());
assertNotNull(faCatchEntity.getAapProcesses());
AapProcessEntity aapProcessEntity = faCatchEntity.getAapProcesses().iterator().next();
assertNotNull(aapProcessEntity);
assertFaCatchFields(faCatch, aapProcessEntity.getFaCatch());
assertNotNull(faCatchEntity.getAapStocks());
AapStockEntity aapStockEntity = faCatchEntity.getAapStocks().iterator().next();
assertNotNull(aapStockEntity);
assertFaCatchFields(faCatch, aapStockEntity.getFaCatch());
assertNotNull(faCatchEntity.getSizeDistribution());
assertFaCatchFields(faCatch, faCatchEntity.getSizeDistribution().getFaCatch());
assertNotNull(faCatchEntity.getFishingGears());
FishingGearEntity fishingGearEntity = faCatchEntity.getFishingGears().iterator().next();
assertNotNull(fishingGearEntity);
assertFaCatchFields(faCatch, fishingGearEntity.getFaCatch());
assertNotNull(faCatchEntity.getFishingTrips());
FishingTripEntity fishingTripEntity = faCatchEntity.getFishingTrips().iterator().next();
assertNotNull(fishingTripEntity);
assertFaCatchFields(faCatch, fishingTripEntity.getFaCatch());
assertNotNull(faCatchEntity.getFluxCharacteristics());
FluxCharacteristicEntity fluxCharacteristicEntity = faCatchEntity.getFluxCharacteristics().iterator().next();
assertNotNull(fluxCharacteristicEntity);
assertFaCatchFields(faCatch, fluxCharacteristicEntity.getFaCatch());
assertNotNull(faCatchEntity.getFluxLocations());
FluxLocationEntity fluxLocationEntity = faCatchEntity.getFluxLocations().iterator().next();
assertNotNull(fluxLocationEntity);
assertFaCatchFields(faCatch, fluxLocationEntity.getFaCatch());
}
use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity 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.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchesProcessorMapper method extractLiveWeight.
private static Double extractLiveWeight(Set<AapProcessEntity> aapProcesses) {
Double totalWeight = null;
Double convFc = 1d;
Double weightSum = 0.0;
if (CollectionUtils.isNotEmpty(aapProcesses)) {
for (AapProcessEntity aapProc : aapProcesses) {
Double actConvFac = aapProc.getConversionFactor();
convFc = (convFc == 1 && actConvFac != null) ? actConvFac : convFc;
addToTotalWeightFromSetOfAapProduct(aapProc.getAapProducts(), weightSum);
}
}
if (weightSum > 0.0) {
totalWeight = convFc * weightSum;
}
return totalWeight;
}
use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchMapper method getAapProcessEntities.
protected Set<AapProcessEntity> getAapProcessEntities(List<AAPProcess> aapProcesses, FaCatchEntity faCatchEntity) {
if (aapProcesses == null || aapProcesses.isEmpty()) {
return Collections.emptySet();
}
Set<AapProcessEntity> aapProcessEntities = new HashSet<>();
for (AAPProcess aapProcess : aapProcesses) {
AapProcessEntity aapProcessEntity = AapProcessMapper.INSTANCE.mapToAapProcessEntity(aapProcess);
aapProcessEntity.setFaCatch(faCatchEntity);
aapProcessEntities.add(aapProcessEntity);
}
return aapProcessEntities;
}
Aggregations