Search in sources :

Example 56 with Asset

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

the class PollRestIT method createPollTest.

/**
 * Creates the poll test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void createPollTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    Map<String, Object> programPollDataMap = MobileTerminalTestHelper.createPoll_Helper(testAsset);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Test(org.junit.Test)

Example 57 with Asset

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

the class PollRestIT method stopProgramPollTest.

/**
 * Stop program poll test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void stopProgramPollTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    Map<String, Object> programPollDataMap = MobileTerminalTestHelper.createPoll_Helper(testAsset);
    ArrayList sendPolls = (ArrayList) programPollDataMap.get("sentPolls");
    String uid = (String) sendPolls.get(0);
    // start it
    {
        final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/start/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
        Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    }
    // stop it
    final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/stop/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    ArrayList values = (ArrayList) dataMap.get("value");
    assertNotNull(values);
    assertTrue(values.size() == 10);
}
Also used : ArrayList(java.util.ArrayList) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) HttpResponse(org.apache.http.HttpResponse) Map(java.util.Map) Test(org.junit.Test)

Example 58 with Asset

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

the class PollRestIT method startProgramPollTest.

/**
 * Start program poll test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void startProgramPollTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    Map<String, Object> programPollDataMap = MobileTerminalTestHelper.createPoll_Helper(testAsset);
    ArrayList sendPolls = (ArrayList) programPollDataMap.get("sentPolls");
    String uid = (String) sendPolls.get(0);
    final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/start/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    ArrayList values = (ArrayList) dataMap.get("value");
    assertNotNull(values);
    assertTrue(values.size() == 10);
}
Also used : ArrayList(java.util.ArrayList) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Example 59 with Asset

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

the class AssetTestHelper method createDummyAsset.

public static Asset createDummyAsset(AssetIdType assetIdType) {
    String ircs = "F" + generateARandomStringWithMaxLength(4);
    Asset asset = new Asset();
    AssetId assetId = new AssetId();
    assetId.setType(assetIdType);
    switch(assetIdType) {
        case GUID:
            assetId.setGuid(UUID.randomUUID().toString());
            break;
        case INTERNAL_ID:
            assetId.setValue("INTERNALID_" + UUID.randomUUID().toString());
            break;
        case CFR:
            String val = UUID.randomUUID().toString().substring(0, 12);
            assetId.setValue(val);
            asset.setCfr(val);
            break;
    }
    asset.setActive(true);
    asset.setAssetId(assetId);
    asset.setSource(CarrierSource.INTERNAL);
    // asset.setEventHistory();
    asset.setName("Ship" + generateARandomStringWithMaxLength(10));
    asset.setCountryCode("SWE");
    asset.setGearType("DERMERSAL");
    asset.setHasIrcs("1");
    asset.setIrcs(ircs);
    asset.setExternalMarking("EXT3");
    String imo = "0" + generateARandomStringWithMaxLength(6);
    asset.setImo(imo);
    String mmsi = generateARandomStringWithMaxLength(9);
    asset.setMmsiNo(mmsi);
    asset.setHasLicense(true);
    asset.setLicenseType("MOCK-license-DB");
    asset.setHomePort("TEST_GOT");
    asset.setLengthOverAll(new BigDecimal(15.0).setScale(1));
    asset.setLengthBetweenPerpendiculars(new BigDecimal(3.0).setScale(1));
    asset.setGrossTonnage(new BigDecimal(200.0).setScale(1));
    asset.setGrossTonnageUnit("OSLO");
    asset.setSafetyGrossTonnage(new BigDecimal(80.0).setScale(1));
    asset.setPowerMain(new BigDecimal(10.0).setScale(1));
    asset.setPowerAux(new BigDecimal(10.0).setScale(1));
    AssetProdOrgModel assetProdOrgModel = new AssetProdOrgModel();
    assetProdOrgModel.setName("NAME" + generateARandomStringWithMaxLength(10));
    assetProdOrgModel.setCity("CITY" + generateARandomStringWithMaxLength(10));
    assetProdOrgModel.setAddress("ADDRESS" + generateARandomStringWithMaxLength(10));
    assetProdOrgModel.setCode("CODE" + generateARandomStringWithMaxLength(10));
    assetProdOrgModel.setPhone("070" + generateARandomStringWithMaxLength(10));
    asset.setProducer(assetProdOrgModel);
    asset.getContact();
    asset.getNotes();
    return asset;
}
Also used : AssetProdOrgModel(eu.europa.ec.fisheries.wsdl.asset.types.AssetProdOrgModel) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetId(eu.europa.ec.fisheries.wsdl.asset.types.AssetId) BigDecimal(java.math.BigDecimal)

Example 60 with Asset

use of eu.europa.ec.fisheries.wsdl.asset.types.Asset 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);
        }
    }
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetListCriteria(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)

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