Search in sources :

Example 1 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class VesselDetailsDTOTest method testEnrichIdentifiers.

@Test
public void testEnrichIdentifiers() throws Exception {
    Asset asset = new Asset();
    asset.setCfr("cfrValueFromAsset");
    AssetIdentifierDto cfr = new AssetIdentifierDto(CFR);
    AssetIdentifierDto ext = new AssetIdentifierDto(EXT_MARK);
    ext.setFaIdentifierId("extMarkingFromActivity");
    AssetIdentifierDto ircs = new AssetIdentifierDto(IRCS);
    ircs.setFaIdentifierId("ircsFromActivity");
    AssetIdentifierDto iccat = new AssetIdentifierDto(ICCAT);
    iccat.setFaIdentifierId("iccat");
    AssetIdentifierDto uvi = new AssetIdentifierDto(UVI);
    Set<AssetIdentifierDto> identifiers = newSet(ircs, cfr, iccat, uvi, ext);
    VesselDetailsDTO dto = builder().vesselIdentifiers(identifiers).build();
    dto.enrichIdentifiers(asset);
    Set<AssetIdentifierDto> vesselIdentifiers = dto.getVesselIdentifiers();
    ImmutableMap<VesselIdentifierSchemeIdEnum, AssetIdentifierDto> map = Maps.uniqueIndex(vesselIdentifiers, new Function<AssetIdentifierDto, VesselIdentifierSchemeIdEnum>() {

        public VesselIdentifierSchemeIdEnum apply(AssetIdentifierDto from) {
            return from.getIdentifierSchemeId();
        }
    });
    AssetIdentifierDto cfr_ = map.get(CFR);
    AssetIdentifierDto ext_ = map.get(EXT_MARK);
    AssetIdentifierDto ircs_ = map.get(IRCS);
    AssetIdentifierDto uvi_ = map.get(UVI);
    AssetIdentifierDto iccat_ = map.get(ICCAT);
    assertTrue(uvi.equals(uvi_));
    assertTrue(ircs.equals(ircs_));
    assertTrue(iccat.equals(iccat_));
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) BaseUnitilsTest(eu.europa.ec.fisheries.uvms.BaseUnitilsTest) Test(org.junit.Test)

Example 2 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO 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 3 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityServiceBeanTest method testGetVesselDetailsAndContactPartiesForFishingTrip.

@Test
@SneakyThrows
public void testGetVesselDetailsAndContactPartiesForFishingTrip() {
    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);
    VesselDetailsDTO vesselDetailsDTO = fishingTripService.getVesselDetailsForFishingTrip("NOR-TRP-20160517234053706");
    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 4 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingOperationViewMapper method getVesselDetailsDTO.

/**
 * Addded this method as we want to set storage information explicitely in VesselDetailsDTO.Storage informaation we can only get from activities
 * @param faEntity
 * @return VesselDetailsDTO
 */
protected List<VesselDetailsDTO> getVesselDetailsDTO(FishingActivityEntity faEntity) {
    if (faEntity == null || CollectionUtils.isEmpty(faEntity.getVesselTransportMeans()))
        return null;
    List<VesselDetailsDTO> vesselDetailsDTOs = new ArrayList<>();
    Set<VesselTransportMeansEntity> entities = faEntity.getVesselTransportMeans();
    for (VesselTransportMeansEntity vesselTransportMeansEntity : entities) {
        VesselDetailsDTO vesselDetails = VesselTransportMeansMapper.INSTANCE.map(vesselTransportMeansEntity);
        if (vesselDetails != null && faEntity.getDestVesselCharId() != null) {
            vesselDetails.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(faEntity.getDestVesselCharId()));
        }
        vesselDetailsDTOs.add(vesselDetails);
    }
    return vesselDetailsDTOs;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList)

Example 5 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getVesselDetailsDTO.

@Nullable
private VesselDetailsDTO getVesselDetailsDTO(VesselTransportMeansEntity vesselTransportMeansEntity, FishingActivityEntity fishingActivityEntity) {
    VesselDetailsDTO detailsDTO;
    detailsDTO = VesselTransportMeansMapper.INSTANCE.map(vesselTransportMeansEntity);
    getMdrCodesEnrichWithAssetsModuleDataIfNeeded(detailsDTO);
    if (fishingActivityEntity != null) {
        VesselStorageCharacteristicsEntity sourceVesselCharId = fishingActivityEntity.getSourceVesselCharId();
        if (detailsDTO != null) {
            detailsDTO.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(sourceVesselCharId));
        }
    }
    return detailsDTO;
}
Also used : VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)10 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 List (java.util.List)3 SneakyThrows (lombok.SneakyThrows)3 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)1 FishingActivityViewDTO (eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)1 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)1 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)1 Nullable (org.jetbrains.annotations.Nullable)1