use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.
the class AssetRestIT method getAssetListTest.
/**
* Gets the asset list test.
*
* @return the asset list test
* @throws Exception
* the exception
*/
@Test
public void getAssetListTest() throws Exception {
Asset asset = AssetTestHelper.createTestAsset();
AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
assetListCriteriaPair.setKey(ConfigSearchField.FLAG_STATE);
assetListCriteriaPair.setValue(asset.getCountryCode());
assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
ListAssetResponse assetListResponse = AssetTestHelper.assetListQuery(assetListQuery);
List<Asset> assets = assetListResponse.getAsset();
assertTrue(assets.contains(asset));
}
use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.
the class AssetRestIT method getAssetListWithLikeSearchValue_CHANGE_KEY_AND_FAIL.
@Test
public void getAssetListWithLikeSearchValue_CHANGE_KEY_AND_FAIL() throws Exception {
Asset asset = AssetTestHelper.createTestAsset();
String guid = asset.getAssetId().getGuid();
String theValue = UUID.randomUUID().toString();
String newName = asset.getName() + "Changed";
asset.setName(newName);
asset.setIccat(theValue);
AssetTestHelper.updateAsset(asset);
AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
AssetListCriteriaPair assetListCriteriaPair_ICCAT = new AssetListCriteriaPair();
assetListCriteriaPair_ICCAT.setKey(ConfigSearchField.ICCAT);
assetListCriteriaPair_ICCAT.setValue(theValue);
AssetListCriteriaPair assetListCriteriaPair_UUID = new AssetListCriteriaPair();
assetListCriteriaPair_UUID.setKey(ConfigSearchField.GUID);
assetListCriteriaPair_UUID.setValue(guid);
assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_ICCAT);
assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_UUID);
ListAssetResponse listAssetResponse = AssetTestHelper.assetListQuery(assetListQuery);
List<Asset> fetchedAsssets = listAssetResponse.getAsset();
assertFalse(fetchedAsssets.contains(asset));
}
use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.
the class AssetTestHelper method getAssetCountSweden.
// ************************************************
// Misc
// ************************************************
public static Integer getAssetCountSweden() throws ClientProtocolException, JsonProcessingException, IOException {
AssetListQuery assetListQuery = getBasicAssetQuery();
AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
assetListCriteriaPair.setKey(ConfigSearchField.FLAG_STATE);
assetListCriteriaPair.setValue("SWE");
assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
final HttpResponse response = Request.Post(getBaseUrl() + "asset/rest/asset/listcount").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(assetListQuery).getBytes()).execute().returnResponse();
return checkSuccessResponseReturnInt(response);
}
use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method enrichWithAssetsModuleDataIfNeeded.
// need confirmation for removal of this method
private void enrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
if (vesselDetailsDTO != null && vesselDetailsDTO.hasEmptyIdentifierValues()) {
try {
Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapToAssetListCriteriaPairList(vesselIdentifiers);
AssetListCriteria criteria = new AssetListCriteria();
criteria.getCriterias().addAll(assetListCriteriaPairs);
AssetListQuery query = new AssetListQuery();
query.setAssetSearchCriteria(criteria);
List<Asset> assetList = assetModuleService.getAssetListResponse(query);
vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
} catch (ServiceException e) {
log.error("Error while trying to send message to Assets module.", e);
}
}
}
Aggregations