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_));
}
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);
}
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);
}
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;
}
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;
}
Aggregations