Search in sources :

Example 31 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.

the class AssetRestIT method getAssetListUpdatedIRCSNotFoundTest.

@Test
public void getAssetListUpdatedIRCSNotFoundTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.IRCS);
    assetListCriteriaPair.setValue(testAsset.getIrcs());
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    ListAssetResponse assetList = AssetTestHelper.assetListQuery(assetListQuery);
    List<Asset> assets = assetList.getAsset();
    assertTrue(assets.contains(testAsset));
    testAsset.setIrcs(testAsset.getIrcs() + "NEW");
    AssetTestHelper.updateAsset(testAsset);
    // Search with same query, the asset should not be found
    assetList = AssetTestHelper.assetListQuery(assetListQuery);
    assets = assetList.getAsset();
    assertFalse(assets.contains(testAsset));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ListAssetResponse(eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 32 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.

the class AssetRestIT method assetListGroupByFlagStateTest.

/**
 * Asset list group by flag state test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void assetListGroupByFlagStateTest() throws Exception {
    Asset asset = AssetTestHelper.createTestAsset();
    ArrayList<String> assetIdList = new ArrayList<String>();
    assetIdList.add(asset.getAssetId().getGuid());
    final HttpResponse response = Request.Post(getBaseUrl() + "asset/rest/asset/listGroupByFlagState").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(assetIdList).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 33 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.

the class AssetRestIT method assetListQueryHistoryGuidTest.

@Test
public void assetListQueryHistoryGuidTest() throws Exception {
    // Create asset versions
    Asset asset1 = AssetTestHelper.createTestAsset();
    Asset asset2 = AssetTestHelper.getAssetByGuid(asset1.getAssetId().getGuid());
    asset2.setName(asset2.getName() + "1");
    asset2 = AssetTestHelper.updateAsset(asset2);
    Asset asset3 = AssetTestHelper.getAssetByGuid(asset2.getAssetId().getGuid());
    asset3.setName(asset3.getName() + "2");
    asset3 = AssetTestHelper.updateAsset(asset3);
    AssetListQuery assetListQuery1 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair.setValue(asset1.getEventHistory().getEventId());
    assetListQuery1.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    ListAssetResponse assetHistory1 = AssetTestHelper.assetListQuery(assetListQuery1);
    List<Asset> assets = assetHistory1.getAsset();
    assertEquals(1, assets.size());
    assertEquals(asset1, assets.get(0));
    AssetListQuery assetListQuery2 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair2 = new AssetListCriteriaPair();
    assetListCriteriaPair2.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair2.setValue(asset2.getEventHistory().getEventId());
    assetListQuery2.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair2);
    ListAssetResponse assetHistory2 = AssetTestHelper.assetListQuery(assetListQuery2);
    List<Asset> assets2 = assetHistory2.getAsset();
    assertEquals(1, assets2.size());
    assertEquals(asset2, assets2.get(0));
    AssetListQuery assetListQuery3 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair3 = new AssetListCriteriaPair();
    assetListCriteriaPair3.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair3.setValue(asset3.getEventHistory().getEventId());
    assetListQuery3.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair3);
    ListAssetResponse assetHistory3 = AssetTestHelper.assetListQuery(assetListQuery3);
    List<Asset> assets3 = assetHistory3.getAsset();
    assertEquals(1, assets3.size());
    assertEquals(asset3, assets3.get(0));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ListAssetResponse(eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 34 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.

the class AssetRestIT method updateAssetAuditLogCreatedTest.

@Test
public void updateAssetAuditLogCreatedTest() throws Exception {
    Date fromDate = DateUtils.getNowDateUTC();
    Asset testAsset = AssetTestHelper.createTestAsset();
    String newName = testAsset.getName() + "Changed";
    testAsset.setName(newName);
    AssetTestHelper.updateAsset(testAsset);
    AssetTestHelper.assertAssetAuditLogCreated(testAsset.getAssetId().getGuid(), AuditOperationEnum.UPDATE, fromDate);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 35 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.

the class AssetGroupRestIT method getAssetGroupListByUserTest.

/**
 * Gets the asset group list by user test.
 *
 * @return the asset group list by user test
 * @throws Exception
 *             the exception
 */
@Test
public void getAssetGroupListByUserTest() throws Exception {
    AssetGroup assetGroup = AssetTestHelper.createBasicAssetGroup();
    Asset asset1 = AssetTestHelper.createTestAsset();
    Asset asset2 = AssetTestHelper.createTestAsset();
    // Add assets to group
    AssetGroupSearchField assetGroupSearchField1 = new AssetGroupSearchField();
    assetGroupSearchField1.setKey(ConfigSearchField.GUID);
    assetGroupSearchField1.setValue(asset1.getAssetId().getGuid());
    assetGroup.getSearchFields().add(assetGroupSearchField1);
    AssetGroupSearchField assetGroupSearchField2 = new AssetGroupSearchField();
    assetGroupSearchField2.setKey(ConfigSearchField.GUID);
    assetGroupSearchField2.setValue(asset2.getAssetId().getGuid());
    assetGroup.getSearchFields().add(assetGroupSearchField2);
    // Create Group
    assetGroup = AssetTestHelper.createAssetGroup(assetGroup);
    assertTrue(assetGroup.getSearchFields().contains(assetGroupSearchField1));
    assertTrue(assetGroup.getSearchFields().contains(assetGroupSearchField2));
    List<AssetGroup> assetGroups = AssetTestHelper.getAssetGroupListByUser(assetGroup.getUser());
    assertTrue(assetGroups.contains(assetGroup));
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetGroupSearchField(eu.europa.ec.fisheries.wsdl.asset.group.AssetGroupSearchField) AssetGroup(eu.europa.ec.fisheries.wsdl.asset.group.AssetGroup) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Aggregations

Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)61 Test (org.junit.Test)54 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)38 MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)15 ArrayList (java.util.ArrayList)14 HttpResponse (org.apache.http.HttpResponse)14 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)13 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)12 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)11 CreateMovementResponse (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 Date (java.util.Date)5 AssetGroup (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroup)4 AssetGroupSearchField (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroupSearchField)4 Map (java.util.Map)4 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)3 List (java.util.List)3 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 LatLong (eu.europa.ec.fisheries.uvms.docker.validation.movement.LatLong)2