use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType in project UVMS-Docker by UnionVMS.
the class MobileTerminalTestHelper method addChannelAttribute.
private static void addChannelAttribute(ComChannelType comChannelType, String type, String value) {
ComChannelAttribute channelAttribute = new ComChannelAttribute();
channelAttribute.setType(type);
channelAttribute.setValue(value);
comChannelType.getAttributes().add(channelAttribute);
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType 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;
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType in project UVMS-Docker by UnionVMS.
the class MobileTerminalTestHelper method addChannelCapability.
private static void addChannelCapability(ComChannelType comChannelType, String type, boolean value) {
ComChannelCapability channelCapability = new ComChannelCapability();
channelCapability.setType(type);
channelCapability.setValue(value);
comChannelType.getCapabilities().add(channelCapability);
}
Aggregations