Search in sources :

Example 71 with SneakyThrows

use of lombok.SneakyThrows 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 72 with SneakyThrows

use of lombok.SneakyThrows 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)

Example 73 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBeanTest method testSaveFishingActivityReportDocuments.

@Test
@SneakyThrows
public void testSaveFishingActivityReportDocuments() throws ServiceException, ParseException, DatatypeConfigurationException {
    // Mock the APIs
    Mockito.doNothing().when(faReportDocumentDao).bulkUploadFaData(Mockito.any(List.class));
    Mockito.doNothing().when(faReportDocumentDao).updateAllFaData(Mockito.any(List.class));
    Mockito.doNothing().when(fluxFaReportMessageDao).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.doReturn(getMockedAssets()).when(assetModule).getAssetGuids(Mockito.anyCollection());
    Mockito.doReturn(getMockedMovements()).when(movementModule).getMovement(Mockito.anyList(), Mockito.any(Date.class), Mockito.any(Date.class));
    Mockito.doReturn(getMockedFishingActivityReportEntity()).when(faReportDocumentDao).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    // Trigger
    fluxMessageService.setDialect(new PostGres());
    fluxMessageService.saveFishingActivityReportDocuments(fluxFaReportMessage, FaReportSourceEnum.FLUX);
    // Verify
    Mockito.verify(fluxFaReportMessageDao, Mockito.times(1)).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).updateAllFaData(captor.capture());
    // Test
    List<FaReportDocumentEntity> faReportDocumentEntities = captor.getValue();
    assertEquals(FaReportStatusEnum.getFaReportStatusEnum(Integer.parseInt(faReportDocuments.get(1).getRelatedFLUXReportDocument().getPurposeCode().getValue())).getStatus(), faReportDocumentEntities.get(0).getStatus());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) List(java.util.List) PostGres(eu.europa.ec.fisheries.ers.service.util.PostGres) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Date(java.util.Date) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 74 with SneakyThrows

use of lombok.SneakyThrows 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 75 with SneakyThrows

use of lombok.SneakyThrows 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));
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) BaseActivityViewMapper(eu.europa.ec.fisheries.ers.service.mapper.view.base.BaseActivityViewMapper) FishingActivityViewDTO(eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)706 lombok.val (lombok.val)314 Test (org.junit.Test)91 ArrayList (java.util.ArrayList)75 HashMap (java.util.HashMap)63 List (java.util.List)53 Cleanup (lombok.Cleanup)38 Map (java.util.Map)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)34 Collectors (java.util.stream.Collectors)34 LinkedHashMap (java.util.LinkedHashMap)30 File (java.io.File)28 Path (java.nio.file.Path)28 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 URL (java.net.URL)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)17