Search in sources :

Example 6 with FaReportDocumentEntity

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

the class TripCatchEvolutionTest method testHandleOnboardCatch.

@Test
public void testHandleOnboardCatch() {
    FaReportDocumentEntity faReportDocumentEntity = ActivityDataUtil.getFaReportDocumentEntity(FaReportDocumentType.DECLARATION.name(), "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), null, null, "new");
    FishingActivityEntity fishingActivityEntity = ActivityDataUtil.getFishingActivityEntity(FishingActivityTypeEnum.FISHING_OPERATION.name(), "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity, null);
    FaCatchEntity faCatchEntity = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity, "LOADED", "FA_CATCH_TYPE", "COD", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", null);
    faCatchEntity.setCalculatedWeightMeasure(11112D);
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivityEntity, FaReportDocumentType.DECLARATION, new HashMap<String, Double>());
    handleOnboardCatch(faCatchEntity, catchEvolutionProgressDTO);
    assertTrue(!catchEvolutionProgressDTO.getCatchEvolution().get("onboard").getSpeciesList().isEmpty());
    assertEquals(catchEvolutionProgressDTO.getCatchEvolution().get("onboard").getSpeciesList().get(0).getSpeciesCode(), "COD");
    assertTrue(catchEvolutionProgressDTO.getCatchEvolution().get("onboard").getSpeciesList().get(0).getWeight() == 11112D);
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 7 with FaReportDocumentEntity

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

the class ActivityServiceBeanTest method testGetFaReportCorrections.

@Test
@SneakyThrows
public void testGetFaReportCorrections() throws ServiceException {
    // Mock
    FaReportDocumentEntity faReportDocumentEntity = MapperUtil.getFaReportDocumentEntity();
    Mockito.doReturn(faReportDocumentEntity).when(faReportDocumentDao).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    // Trigger
    List<FaReportCorrectionDTO> faReportCorrectionDTOList = activityService.getFaReportCorrections("TEST ID", "SCHEME ID");
    // Verify
    Mockito.verify(faReportDocumentDao, Mockito.times(1)).findFaReportByIdAndScheme("TEST ID", "SCHEME ID");
    // Test
    FaReportCorrectionDTO faReportCorrectionDTO = faReportCorrectionDTOList.get(0);
    assertEquals(faReportDocumentEntity.getStatus(), faReportCorrectionDTO.getCorrectionType());
    assertEquals(faReportDocumentEntity.getFluxReportDocument().getCreationDatetime(), faReportCorrectionDTO.getCreationDate());
    assertEquals(faReportDocumentEntity.getAcceptedDatetime(), faReportCorrectionDTO.getAcceptedDate());
    assertEquals(faReportDocumentEntity.getFluxReportDocument().getFluxReportIdentifiers().iterator().next().getFluxReportIdentifierId(), faReportCorrectionDTO.getFaReportIdentifiers().entrySet().iterator().next().getKey());
    assertEquals(faReportDocumentEntity.getFluxReportDocument().getFluxReportIdentifiers().iterator().next().getFluxReportIdentifierSchemeId(), faReportCorrectionDTO.getFaReportIdentifiers().entrySet().iterator().next().getValue());
    assertEquals(faReportDocumentEntity.getFluxReportDocument().getFluxParty().getFluxPartyName(), faReportCorrectionDTO.getOwnerFluxPartyName());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FaReportCorrectionDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.FaReportCorrectionDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 8 with FaReportDocumentEntity

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

the class ActivityDataUtil method getFaCatchesEntities.

public static List<FaCatchEntity> getFaCatchesEntities() {
    List<FaCatchEntity> faCatchEntities = new ArrayList<>();
    FluxReportDocumentEntity fluxReportDocumentEntity1 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT1", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID1", "flux1");
    VesselTransportMeansEntity vesselTransportMeansEntity1 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup1", null);
    vesselTransportMeansEntity1.setVesselIdentifiers(ActivityDataUtil.getVesselIdentifiers(vesselTransportMeansEntity1, "IDENT_1", "CFR"));
    FaReportDocumentEntity faReportDocumentEntity1 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity1, vesselTransportMeansEntity1, "new");
    FishingActivityEntity fishingActivityEntity1 = ActivityDataUtil.getFishingActivityEntity("DEPARTURE", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity1, null);
    SizeDistributionEntity sizeDistributionEntity = ActivityDataUtil.getSizeDistributionEntity("LSC", "FISH_SIZE_CLASS", "BFT", "FA_BFT_SIZE_CATEGORY");
    FaCatchEntity faCatchEntity1 = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "LOADED", "FA_CATCH_TYPE", "COD", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
    FaCatchEntity faCatchEntity2 = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "ONBOARD", "FA_CATCH_TYPE", "HKE", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
    FaCatchEntity faCatchEntity3 = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "UNLOADED", "FA_CATCH_TYPE", "HAD", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
    FaCatchEntity faCatchEntity4 = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "DEMINIMIS", "FA_CATCH_TYPE", "POK", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
    faCatchEntities.add(faCatchEntity1);
    faCatchEntities.add(faCatchEntity2);
    faCatchEntities.add(faCatchEntity3);
    faCatchEntities.add(faCatchEntity4);
    return faCatchEntities;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) SizeDistributionEntity(eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 9 with FaReportDocumentEntity

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

the class FishingActivityViewMapperTest method initFishingActivityEntity.

@Before
@SneakyThrows
public void initFishingActivityEntity() {
    FLUXFAReportMessage fluxfaReportMessage = getActivityDataFromXML();
    FluxFaReportMessageEntity fluxRepMessageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.FLUX, new FluxFaReportMessageEntity());
    List<FaReportDocumentEntity> faReportDocuments = new ArrayList<>(fluxRepMessageEntity.getFaReportDocuments());
    fishingActivity = faReportDocuments.get(0).getFishingActivities().iterator().next();
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) ArrayList(java.util.ArrayList) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 10 with FaReportDocumentEntity

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

the class FluxFaReportMessageMapperTest method testFluxFaReportMessageMapper.

@Test
@SneakyThrows
public void testFluxFaReportMessageMapper() {
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("fa_flux_message.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(FLUXFAReportMessage.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    FLUXFAReportMessage fluxfaReportMessage = (FLUXFAReportMessage) jaxbUnmarshaller.unmarshal(is);
    FluxFaReportMessageEntity fluxRepMessageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.FLUX, new FluxFaReportMessageEntity());
    List<FaReportDocumentEntity> faReportDocuments = new ArrayList(fluxRepMessageEntity.getFaReportDocuments());
    FluxReportDocumentEntity fluxReportDocument = fluxRepMessageEntity.getFluxReportDocument();
    assertNotNull(fluxRepMessageEntity);
    assertNotNull(fluxReportDocument);
    assertNotNull(fluxReportDocument.getFluxFaReportMessage());
    assertNotNull(faReportDocuments.get(0).getFluxReportDocument());
    assertEquals(1, faReportDocuments.size());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)24 ArrayList (java.util.ArrayList)10 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)8 Test (org.junit.Test)7 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)5 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)5 FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)4 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)4 SneakyThrows (lombok.SneakyThrows)4 FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)4 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 ParseException (com.vividsolutions.jts.io.ParseException)2 FaReportIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity)2 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)2 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)2 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)1