Search in sources :

Example 76 with SneakyThrows

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

the class FishingActivityViewMapperTest method testActivityArrivalViewMapper.

@Test
@SneakyThrows
public void testActivityArrivalViewMapper() {
    BaseActivityViewMapper mapperForView = ActivityViewMapperFactory.getMapperForView(ActivityViewEnum.ARRIVAL);
    FishingActivityViewDTO fishingActivityViewDTO = mapperForView.mapFaEntityToFaDto(getFishingActivityEntity());
    assertNotNull(fishingActivityViewDTO.getActivityDetails());
    assertNotNull(fishingActivityViewDTO.getGears());
    assertNotNull(fishingActivityViewDTO.getReportDetails());
    assertTrue(fishingActivityViewDTO.getGears().size() == 1);
    assertNull(mapperForView.mapFaEntityToFaDto(null));
// printDtoOnConsole(fishingActivityViewDTO, FishingActivityView.Arrival.class);
}
Also used : BaseActivityViewMapper(eu.europa.ec.fisheries.ers.service.mapper.view.base.BaseActivityViewMapper) FishingActivityViewDTO(eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 77 with SneakyThrows

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

Example 78 with SneakyThrows

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

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

the class FishingActivityServiceBeanTest method testGetVesselDetailsForFishingTrip.

@Test
@SneakyThrows
public void testGetVesselDetailsForFishingTrip() throws ServiceException {
    Map<String, List<String>> returnMap = new HashMap<>();
    returnMap.put("code", new ArrayList<String>());
    when(vesselTransportMeansDao.findLatestVesselByTripId("NOR-TRP-20160517234053706")).thenReturn(new VesselTransportMeansEntity());
    when(mdrModuleServiceBean.getAcronymFromMdr("FLUX_VESSEL_ID_TYPE", "*", new ArrayList<String>(), 9999999, "code")).thenReturn(returnMap);
    // Trigger
    VesselDetailsDTO vesselDetailsDTO = fishingTripService.getVesselDetailsForFishingTrip("NOR-TRP-20160517234053706");
    Mockito.verify(vesselTransportMeansDao, Mockito.times(1)).findLatestVesselByTripId(Mockito.any(String.class));
    // Verify
    assertNotNull(vesselDetailsDTO);
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) HashMap(java.util.HashMap) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 80 with SneakyThrows

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

the class FaReportDocumentDaoTest method testInsertTable.

@Test
@SneakyThrows
@Transactional
public void testInsertTable() throws Exception {
    dbSetupTracker.skipNextLaunch();
    List<FaReportDocumentEntity> faReportDocumentEntities = new ArrayList<>();
    FAReportDocument faReportDocument = MapperUtil.getFaReportDocument();
    FaReportDocumentEntity faReportDocumentEntity = FaReportDocumentMapper.INSTANCE.mapToFAReportDocumentEntity(faReportDocument, new FaReportDocumentEntity(), FaReportSourceEnum.FLUX);
    faReportDocumentEntities.add(faReportDocumentEntity);
    insertIntoDB(faReportDocumentEntities);
    List<FaReportDocumentEntity> entityList = dao.findAllEntity(FaReportDocumentEntity.class);
    assertNotNull(entityList);
    assertNotEquals(0, entityList.size());
}
Also used : ArrayList(java.util.ArrayList) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows) Transactional(javax.transaction.Transactional)

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