use of cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl in project c2mon by c2mon.
the class QueryObjTest method mandatoryKeyForClassWithoutTargetShouldThrowError.
@Test
void mandatoryKeyForClassWithoutTargetShouldThrowError() throws DynConfigException {
QueryKey<String> mode = new QueryKey<>("mode", "GET", true);
mode.setVerifier(s -> s.equalsIgnoreCase("GET") || s.equalsIgnoreCase("POST"));
URI uri = URI.create("opc.tcp://host:500/path?mode=GET");
QueryObj queryObj = new QueryObj(uri, Collections.singletonList(mode));
DataTag.CreateBuilder builder = DataTag.create("a", Object.class, new DataTagAddress(new HardwareAddressImpl()));
assertThrows(DynConfigException.class, () -> queryObj.applyQueryPropertiesTo(builder));
}
use of cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl in project c2mon by c2mon.
the class QueryObjTest method mandatoryKeyForClassWithTargetShouldPassWork.
@Test
void mandatoryKeyForClassWithTargetShouldPassWork() throws DynConfigException {
QueryKey<String> mode = new QueryKey<>("mode", "GET", true);
mode.setVerifier(s -> s.equalsIgnoreCase("GET") || s.equalsIgnoreCase("POST"));
mode.setTargetClass(DataTagAddress.class);
URI uri = URI.create("opc.tcp://host:500/path?mode=GET");
QueryObj queryObj = new QueryObj(uri, Collections.singletonList(mode));
DataTag.CreateBuilder builder = DataTag.create("a", Object.class, new DataTagAddress(new HardwareAddressImpl()));
queryObj.applyQueryPropertiesTo(builder);
}
use of cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl in project c2mon by c2mon.
the class RestConfigStrategyTest method prepareTagConfigurationsShouldIncludeAllPropertiesInKeys.
@Test
void prepareTagConfigurationsShouldIncludeAllPropertiesInKeys() throws DynConfigException {
DataTagAddress expected = new DataTagAddress(new HardwareAddressImpl());
HashMap<String, String> parameters = new HashMap<>();
parameters.put("url", "xxx");
parameters.put("mode", "POST");
parameters.put("getFrequency", "5");
parameters.put("postFrequency", "3");
parameters.put("jsonPathExpression", "aa");
expected.setAddressParameters(parameters);
URI uri = URI.create("http://host/path?url=xxx&mode=POST&getFrequency=5&postFrequency=3&jsonPathExpression=aa");
strategy = ITagConfigStrategy.of(uri);
DataTagAddress actual = this.strategy.prepareDataTagConfigurations().getAddress();
assertEquals(expected, actual);
}
use of cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl in project c2mon by c2mon.
the class RestConfigStrategy method prepareDataTagConfigurations.
/**
* Create appropriate preliminary data tag configurations with a @{@link cern.c2mon.shared.common.datatag.address.DIPHardwareAddress}
* which can then be passed to the C2MON server for creation.
* @return the preliminary DataTags to pass on to the C2MON server for creation.
* @throws DynConfigException if a value in the query cannot be converted to the necessary class, but is mandatory.
*/
public DataTag prepareDataTagConfigurations() throws DynConfigException {
HardwareAddress restHardwareAddress = new HardwareAddressImpl();
DataTag dataTag = super.toTagConfiguration(restHardwareAddress);
HashMap<String, String> params = keys.stream().filter(k -> queryObj.contains(k)).collect(Collectors.toMap(QueryKey::getKeyName, o -> StringUtils.join(queryObj.get(o, String.class), ", "), (o, o2) -> o, HashMap::new));
dataTag.getAddress().setAddressParameters(params);
return dataTag;
}
Aggregations