Search in sources :

Example 1 with FishingTripIdentifierEntity

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

the class MapperUtil method getFishingTripEntity.

public static FishingTripEntity getFishingTripEntity() {
    FishingTripEntity entity = new FishingTripEntity();
    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");
    FluxReportDocumentEntity fluxReportDocumentEntity2 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT2", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID2", "flux2");
    FluxReportDocumentEntity fluxReportDocumentEntity3 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT3", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID3", "flux3");
    FluxReportDocumentEntity fluxReportDocumentEntity4 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT4", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID4", "flux4");
    VesselTransportMeansEntity vesselTransportMeansEntity1 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup1", null);
    VesselTransportMeansEntity vesselTransportMeansEntity2 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup2", null);
    VesselTransportMeansEntity vesselTransportMeansEntity3 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup3", 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");
    FaReportDocumentEntity faReportDocumentEntity2 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity2, vesselTransportMeansEntity2, "new");
    FaReportDocumentEntity faReportDocumentEntity3 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity3, vesselTransportMeansEntity3, "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);
    FishingActivityEntity fishingActivityEntity2 = ActivityDataUtil.getFishingActivityEntity("ARRIVAL", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity2, null);
    FishingActivityEntity fishingActivityEntity3 = ActivityDataUtil.getFishingActivityEntity("LANDING", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity3, null);
    SizeDistributionEntity sizeDistributionEntity = ActivityDataUtil.getSizeDistributionEntity("LSC", "FISH_SIZE_CLASS", "BFT", "FA_BFT_SIZE_CATEGORY");
    FaCatchEntity faCatchEntity = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "DEPARTURE", "FA_CATCH_TYPE", "beagle2", "FAO_SPECIES", 11112D, 11112.0D, "FLUX_UNIT", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
    entity = ActivityDataUtil.getFishingTripEntity("JFO", "EU_TRIP_ID", faCatchEntity, fishingActivityEntity1);
    Set<FishingTripIdentifierEntity> fishingTripIdentifiers = new HashSet<>();
    fishingTripIdentifiers.add(ActivityDataUtil.getFishingTripIdentifierEntity(entity, "NOR-TRP-20160517234053706", "EU_TRIP_ID"));
    fishingTripIdentifiers.add(ActivityDataUtil.getFishingTripIdentifierEntity(entity, "NOR-TRP-20160517234053706", "EU_TRIP_ID"));
    entity.setFishingTripIdentifiers(fishingTripIdentifiers);
    return entity;
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) 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) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) SizeDistributionEntity(eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Example 2 with FishingTripIdentifierEntity

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

the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_OnlyCurrentAndSelected.

@Test
@SneakyThrows
public void getCronologyOfFishingTrip_OnlyCurrentAndSelected() {
    // Mock the Dao
    doReturn(getVesselIdentifiers()).when(vesselIdentifiersDao).getLatestVesselIdByTrip(any(String.class));
    FishingTripIdentifierEntity fishingTripIdentifierEntity = getCurrentTrip();
    doReturn(fishingTripIdentifierEntity).when(fishingTripIdentifierDao).getCurrentTrip(any(String.class), any(String.class));
    List<FishingTripIdentifierEntity> previousTrips = getPreviousTrips(5);
    doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    List<FishingTripIdentifierEntity> nextTrips = getNextTrips(5);
    doReturn(nextTrips).when(fishingTripIdentifierDao).getNextTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    // Trigger
    String selectedTrip = "selected Trip";
    CronologyTripDTO cronology = fishingTripService.getCronologyOfFishingTrip(selectedTrip, 1);
    assertEquals(selectedTrip, cronology.getSelectedTrip());
    assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
    assertEquals(0, cronology.getPreviousTrips().size());
    assertEquals(0, cronology.getNextTrips().size());
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) CronologyTripDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 3 with FishingTripIdentifierEntity

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

the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_OnlyPrevious.

@Test
@SneakyThrows
public void getCronologyOfFishingTrip_OnlyPrevious() {
    // Mock the Dao
    doReturn(getVesselIdentifiers()).when(vesselIdentifiersDao).getLatestVesselIdByTrip(any(String.class));
    FishingTripIdentifierEntity fishingTripIdentifierEntity = getCurrentTrip();
    doReturn(fishingTripIdentifierEntity).when(fishingTripIdentifierDao).getCurrentTrip(any(String.class), any(String.class));
    List<FishingTripIdentifierEntity> previousTrips = getPreviousTrips(2);
    doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    List<FishingTripIdentifierEntity> nextTrips = getNextTrips(2);
    doReturn(nextTrips).when(fishingTripIdentifierDao).getNextTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    // Trigger
    String selectedTrip = "selected Trip";
    CronologyTripDTO cronology = fishingTripService.getCronologyOfFishingTrip(selectedTrip, 2);
    assertEquals(selectedTrip, cronology.getSelectedTrip());
    assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
    List<String> previousIds = getIds(previousTrips);
    assertEquals(previousIds.subList(1, previousIds.size()), cronology.getPreviousTrips());
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) CronologyTripDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 4 with FishingTripIdentifierEntity

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

the class FishingTripServiceBeanTest method getCurrentTrip.

public FishingTripIdentifierEntity getCurrentTrip() {
    FishingTripIdentifierEntity identifier = new FishingTripIdentifierEntity();
    identifier.setTripId("Current Trip");
    identifier.setTripSchemeId("Current Trip scheme Id");
    return identifier;
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Example 5 with FishingTripIdentifierEntity

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

the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_All.

@Test
@SneakyThrows
public void getCronologyOfFishingTrip_All() {
    // Mock the Dao
    doReturn(getVesselIdentifiers()).when(vesselIdentifiersDao).getLatestVesselIdByTrip(any(String.class));
    FishingTripIdentifierEntity fishingTripIdentifierEntity = getCurrentTrip();
    doReturn(fishingTripIdentifierEntity).when(fishingTripIdentifierDao).getCurrentTrip(any(String.class), any(String.class));
    List<FishingTripIdentifierEntity> previousTrips = getPreviousTrips(10);
    doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    List<FishingTripIdentifierEntity> nextTrips = getNextTrips(10);
    doReturn(nextTrips).when(fishingTripIdentifierDao).getNextTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
    // Trigger
    String selectedTrip = "selected Trip";
    CronologyTripDTO cronology = fishingTripService.getCronologyOfFishingTrip(selectedTrip, 0);
    assertEquals(selectedTrip, cronology.getSelectedTrip());
    assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
    List<String> previousIds = getIds(previousTrips);
    assertEquals(previousIds, cronology.getPreviousTrips());
    List<String> nextIds = getIds(nextTrips);
    assertEquals(nextIds, cronology.getNextTrips());
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) CronologyTripDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)18 ArrayList (java.util.ArrayList)5 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 CronologyTripDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO)4 SneakyThrows (lombok.SneakyThrows)4 Test (org.junit.Test)4 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)3 VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)2 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 ParseException (com.vividsolutions.jts.io.ParseException)1 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)1 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)1 FishingActivityTypeDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO)1