use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity 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.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapperTest method testSpeciesCodeWithNullShouldNotBeMapped.
@Test
public void testSpeciesCodeWithNullShouldNotBeMapped() {
FaCatchEntity faCatchEntity = new FaCatchEntity();
faCatchEntity.setSpeciesCode(null);
FishingActivityEntity fa = FishingActivityEntity.builder().build();
fa.setFaCatchs(newSet(faCatchEntity));
List<String> speciesCode = FishingActivityMapper.INSTANCE.getSpeciesCode(fa);
assertEquals(0, speciesCode.size());
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity 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.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityViewMapperTest method testActivityRelocationViewMapper.
@Test
@SneakyThrows
public void testActivityRelocationViewMapper() {
BaseActivityViewMapper mapperForView = ActivityViewMapperFactory.getMapperForView(ActivityViewEnum.RELOCATION);
FishingActivityEntity fishingActivityEntity = getFishingActivityEntity();
Set<FaCatchEntity> faCatches = generateFaCatches(fishingActivityEntity.getFaCatchs().iterator().next());
fishingActivityEntity.setFaCatchs(faCatches);
FishingActivityViewDTO fishingActivityViewDTO = mapperForView.mapFaEntityToFaDto(fishingActivityEntity);
assertNotNull(fishingActivityViewDTO.getActivityDetails());
assertNotNull(fishingActivityViewDTO.getReportDetails());
assertNull(ActivityArrivalViewMapper.INSTANCE.mapFaEntityToFaDto(null));
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ARRCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.
@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.NOTIFICATION) {
return null;
}
CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
boolean onboardXorUnloaded = (faCatchType == FaCatchTypeEnum.ONBOARD && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.UNLOADED)) || (faCatchType == FaCatchTypeEnum.UNLOADED && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.ONBOARD));
if (onboardXorUnloaded) {
handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
}
}
return catchEvolutionProgressDTO;
}
Aggregations