Search in sources :

Example 1 with MobileTerminalAttribute

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

the class MobileTerminalTestHelper method createPoll_Helper.

public static Map<String, Object> createPoll_Helper(Asset testAsset) throws Exception {
    MobileTerminalType createdMobileTerminalType = createMobileTerminalType();
    {
        MobileTerminalAssignQuery mobileTerminalAssignQuery = new MobileTerminalAssignQuery();
        mobileTerminalAssignQuery.setMobileTerminalId(createdMobileTerminalType.getMobileTerminalId());
        mobileTerminalAssignQuery.setConnectId(testAsset.getAssetId().getGuid());
        // Assign first
        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);
    }
    String comChannelId = createdMobileTerminalType.getChannels().get(0).getGuid();
    PollRequestType pollRequestType = new PollRequestType();
    pollRequestType.setPollType(PollType.PROGRAM_POLL);
    pollRequestType.setUserName("vms_admin_com");
    pollRequestType.setComment("Manual poll created by test");
    PollMobileTerminal pollMobileTerminal = new PollMobileTerminal();
    pollMobileTerminal.setComChannelId(comChannelId);
    pollMobileTerminal.setConnectId(testAsset.getAssetId().getGuid());
    pollMobileTerminal.setMobileTerminalId(createdMobileTerminalType.getMobileTerminalId().getGuid());
    List<MobileTerminalAttribute> mobileTerminalAttributes = createdMobileTerminalType.getAttributes();
    List<PollAttribute> pollAttributes = pollRequestType.getAttributes();
    for (MobileTerminalAttribute mobileTerminalAttribute : mobileTerminalAttributes) {
        String type = mobileTerminalAttribute.getType();
        String value = mobileTerminalAttribute.getValue();
        PollAttribute pollAttribute = new PollAttribute();
        try {
            PollAttributeType pollAttributeType = PollAttributeType.valueOf(type);
            pollAttribute.setKey(pollAttributeType);
            pollAttribute.setValue(value);
            pollAttributes.add(pollAttribute);
        } catch (RuntimeException rte) {
        // ignore
        }
    }
    PollAttribute frequency = new PollAttribute();
    PollAttribute startDate = new PollAttribute();
    PollAttribute endDate = new PollAttribute();
    pollAttributes.add(frequency);
    frequency.setKey(PollAttributeType.FREQUENCY);
    frequency.setValue("1000");
    pollAttributes.add(startDate);
    startDate.setKey(PollAttributeType.START_DATE);
    startDate.setValue(getDateAsString(2001, Calendar.JANUARY, 7, 1, 7, 23, 45));
    pollAttributes.add(endDate);
    endDate.setKey(PollAttributeType.END_DATE);
    endDate.setValue(getDateAsString(2027, Calendar.DECEMBER, 24, 11, 45, 7, 980));
    pollRequestType.getMobileTerminals().add(pollMobileTerminal);
    final HttpResponse response = Request.Post(getBaseUrl() + "mobileterminal/rest/poll").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(pollRequestType).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    return dataMap;
}
Also used : PollRequestType(eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollRequestType) PollAttributeType(eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollAttributeType) PollMobileTerminal(eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollMobileTerminal) HttpResponse(org.apache.http.HttpResponse) MobileTerminalAssignQuery(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAssignQuery) PollAttribute(eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollAttribute) MobileTerminalAttribute(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Map(java.util.Map)

Example 2 with MobileTerminalAttribute

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

the class MobileTerminalTestHelper method addAttribute.

private static void addAttribute(List<MobileTerminalAttribute> attributes, String type, String value) {
    MobileTerminalAttribute serialNumberMobileTerminalAttribute = new MobileTerminalAttribute();
    serialNumberMobileTerminalAttribute.setType(type);
    serialNumberMobileTerminalAttribute.setValue(value);
    attributes.add(serialNumberMobileTerminalAttribute);
}
Also used : MobileTerminalAttribute(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute)

Example 3 with MobileTerminalAttribute

use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute 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)

Aggregations

MobileTerminalAttribute (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute)3 MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)2 Map (java.util.Map)2 HttpResponse (org.apache.http.HttpResponse)2 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 PollRequestType (eu.europa.ec.fisheries.schema.mobileterminal.polltypes.v1.PollRequestType)1 ComChannelType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType)1 MobileTerminalAssignQuery (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAssignQuery)1 MobileTerminalId (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalId)1 Plugin (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin)1 ArrayList (java.util.ArrayList)1