Search in sources :

Example 21 with MobileTerminalType

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType in project UVMS-Docker by UnionVMS.

the class MobileTerminalRestIT method assignMobileTerminalTest.

/**
 * Assign mobile terminal test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void assignMobileTerminalTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    MobileTerminalType createdMobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    Map<String, Object> dataMap = MobileTerminalTestHelper.assignMobileTerminal(testAsset, createdMobileTerminalType);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Test(org.junit.Test)

Example 22 with MobileTerminalType

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType in project UVMS-Docker by UnionVMS.

the class MobileTerminalRestIT method getMobileTerminalByIdTest.

/**
 * Gets the mobile terminal by id test.
 *
 * @return the mobile terminal by id test
 * @throws Exception
 *             the exception
 */
@Test
public void getMobileTerminalByIdTest() throws Exception {
    MobileTerminalType createdMobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    final HttpResponse response = Request.Get(getBaseUrl() + "mobileterminal/rest/mobileterminal/" + createdMobileTerminalType.getMobileTerminalId().getGuid()).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : HttpResponse(org.apache.http.HttpResponse) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Test(org.junit.Test)

Example 23 with MobileTerminalType

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType in project UVMS-Docker by UnionVMS.

the class MobileTerminalRestIT method getMobileTerminalHistoryListByMobileTerminalIdTest.

/**
 * Gets the mobile terminal history list by mobile terminal id test.
 *
 * @return the mobile terminal history list by mobile terminal id test
 * @throws Exception
 *             the exception
 */
@Test
public void getMobileTerminalHistoryListByMobileTerminalIdTest() throws Exception {
    MobileTerminalType createdMobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    final HttpResponse response = Request.Get(getBaseUrl() + "mobileterminal/rest/mobileterminal/history/" + createdMobileTerminalType.getMobileTerminalId().getGuid()).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : HttpResponse(org.apache.http.HttpResponse) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Test(org.junit.Test)

Example 24 with MobileTerminalType

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType in project UVMS-Docker by UnionVMS.

the class MobileTerminalTestHelper method createMobileTerminalType.

public static MobileTerminalType createMobileTerminalType() throws IOException, ClientProtocolException, JsonProcessingException, JsonParseException, JsonMappingException {
    MobileTerminalType mobileTerminalRequest = new MobileTerminalType();
    mobileTerminalRequest.setSource(MobileTerminalSource.INTERNAL);
    mobileTerminalRequest.setType("INMARSAT_C");
    List<MobileTerminalAttribute> attributes = mobileTerminalRequest.getAttributes();
    addAttribute(attributes, "SERIAL_NUMBER", AssetTestHelper.generateARandomStringWithMaxLength(10));
    addAttribute(attributes, "SATELLITE_NUMBER", "S" + AssetTestHelper.generateARandomStringWithMaxLength(4));
    addAttribute(attributes, "ANTENNA", "A");
    addAttribute(attributes, "TRANSCEIVER_TYPE", "A");
    addAttribute(attributes, "SOFTWARE_VERSION", "A");
    List<ComChannelType> channels = mobileTerminalRequest.getChannels();
    ComChannelType comChannelType = new ComChannelType();
    channels.add(comChannelType);
    comChannelType.setGuid(UUID.randomUUID().toString());
    comChannelType.setName("VMS");
    addChannelAttribute(comChannelType, "FREQUENCY_GRACE_PERIOD", "54000");
    addChannelAttribute(comChannelType, "MEMBER_NUMBER", "100");
    addChannelAttribute(comChannelType, "FREQUENCY_EXPECTED", "7200");
    addChannelAttribute(comChannelType, "FREQUENCY_IN_PORT", "10800");
    addChannelAttribute(comChannelType, "LES_DESCRIPTION", "Thrane&Thrane");
    addChannelAttribute(comChannelType, "DNID", "1" + AssetTestHelper.generateARandomStringWithMaxLength(3));
    addChannelAttribute(comChannelType, "INSTALLED_BY", "Mike Great");
    addChannelCapability(comChannelType, "POLLABLE", true);
    addChannelCapability(comChannelType, "CONFIGURABLE", true);
    addChannelCapability(comChannelType, "DEFAULT_REPORTING", true);
    Plugin plugin = new Plugin();
    plugin.setServiceName("eu.europa.ec.fisheries.uvms.plugins.inmarsat");
    plugin.setLabelName("Thrane&Thrane");
    plugin.setSatelliteType("INMARSAT_C");
    plugin.setInactive(false);
    mobileTerminalRequest.setPlugin(plugin);
    final HttpResponse response = Request.Post(getBaseUrl() + "mobileterminal/rest/mobileterminal").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(mobileTerminalRequest).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    Map<String, Object> assetMap = (Map<String, Object>) dataMap.get("mobileTerminalId");
    assertNotNull(assetMap);
    String mobileTerminalGuid = (String) assetMap.get("guid");
    assertNotNull(mobileTerminalGuid);
    ArrayList channelsList = (ArrayList) dataMap.get("channels");
    assertNotNull(channelsList);
    Map<String, Object> channelMap = (Map<String, Object>) channelsList.get(0);
    assertNotNull(channelMap);
    String channelGuid = (String) channelMap.get("guid");
    comChannelType.setGuid(channelGuid);
    mobileTerminalRequest.setId((Integer) dataMap.get("id"));
    MobileTerminalId mobileTerminalId = new MobileTerminalId();
    mobileTerminalId.setGuid(mobileTerminalGuid);
    mobileTerminalRequest.setMobileTerminalId(mobileTerminalId);
    return mobileTerminalRequest;
}
Also used : ComChannelType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) MobileTerminalId(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalId) MobileTerminalAttribute(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Map(java.util.Map) Plugin(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin)

Example 25 with MobileTerminalType

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType in project UVMS-Docker by UnionVMS.

the class MobileTerminalTestHelper method assignMobileTerminal.

public static Map<String, Object> assignMobileTerminal(Asset testAsset, MobileTerminalType createdMobileTerminalType) throws Exception {
    MobileTerminalAssignQuery mobileTerminalAssignQuery = new MobileTerminalAssignQuery();
    mobileTerminalAssignQuery.setMobileTerminalId(createdMobileTerminalType.getMobileTerminalId());
    mobileTerminalAssignQuery.setConnectId(testAsset.getAssetId().getGuid());
    createdMobileTerminalType.setConnectId(testAsset.getAssetId().getGuid());
    final HttpResponse response = Request.Post(getBaseUrl() + "mobileterminal/rest/mobileterminal/assign?comment=comment").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(mobileTerminalAssignQuery).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    return dataMap;
}
Also used : HttpResponse(org.apache.http.HttpResponse) MobileTerminalAssignQuery(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAssignQuery)

Aggregations

MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)24 Test (org.junit.Test)21 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)15 HttpResponse (org.apache.http.HttpResponse)14 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)13 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)12 CreateMovementResponse (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse)10 ArrayList (java.util.ArrayList)6 MobileTerminalAssignQuery (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAssignQuery)3 LatLong (eu.europa.ec.fisheries.uvms.docker.validation.movement.LatLong)3 Date (java.util.Date)3 Map (java.util.Map)3 MobileTerminalAttribute (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute)2 List (java.util.List)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 PollAttribute (eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollAttribute)1 PollAttributeType (eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollAttributeType)1 PollMobileTerminal (eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollMobileTerminal)1