use of cern.c2mon.shared.common.datatag.DataTagAddress 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.DataTagAddress 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.DataTagAddress 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.DataTagAddress in project c2mon by c2mon.
the class RequestControllerTest method getBasicConfigurationController.
/**
* @return configurationController
*/
private ConfigurationController getBasicConfigurationController() {
ConfigurationController configurationController = new ConfigurationController();
ProcessConfiguration processConfiguration = new ProcessConfiguration();
EquipmentConfiguration equipmentConfiguration = new EquipmentConfiguration();
EquipmentConfiguration equipmentConfiguration2 = new EquipmentConfiguration();
SourceCommandTag commandTag = new SourceCommandTag(1L, "hello");
DataTagAddress address = new DataTagAddress();
SourceDataTag sourceDataTag = new SourceDataTag(1L, "asd", false, (short) 0, "Integer", address);
SourceDataTag sourceDataTag2 = new SourceDataTag(2L, "asd", false, (short) 0, "Integer", address);
SourceDataTag sourceDataTag3 = new SourceDataTag(3L, "asd", false, (short) 0, "Integer", address);
processConfiguration.setProcessID(1L);
equipmentConfiguration.setId(1L);
sourceDataTag.update(new ValueUpdate(25));
sourceDataTag2.update(new ValueUpdate(25));
sourceDataTag3.update(new ValueUpdate(25));
configurationController.setProcessConfiguration(processConfiguration);
processConfiguration.getEquipmentConfigurations().put(1L, equipmentConfiguration);
processConfiguration.getEquipmentConfigurations().put(2L, equipmentConfiguration2);
equipmentConfiguration.getCommandTags().put(1L, commandTag);
equipmentConfiguration.getDataTags().put(1L, sourceDataTag);
equipmentConfiguration2.getDataTags().put(2L, sourceDataTag2);
equipmentConfiguration2.getDataTags().put(3L, sourceDataTag3);
return configurationController;
}
use of cern.c2mon.shared.common.datatag.DataTagAddress in project c2mon by c2mon.
the class CacheObjectCreation method createTestDataTag3.
/**
* Need to first insert test equipment using EquipmentMapper
* @return the DataTag
*/
public static DataTagCacheObject createTestDataTag3() {
// construct fake DataTagCacheObject, setting all fields
DataTagCacheObject cacheObject = new DataTagCacheObject();
// must be non null in DB
cacheObject.setId(Long.valueOf(100003));
// non null
cacheObject.setName("Junit_test_datatag3");
cacheObject.setDescription("test description");
// non null
cacheObject.setMode(DataTagConstants.MODE_TEST);
// non null
cacheObject.setDataType("String");
// cacheObject.setTopic("tim.testdatatag.XADDRESS");
// null allowed
cacheObject.setLogged(false);
cacheObject.setUnit("test unit");
cacheObject.setDipAddress("testDIPaddress");
cacheObject.setJapcAddress("testJAPCaddress");
cacheObject.setValue("DOWN");
cacheObject.setValueDescription("test value description");
// null allowed
cacheObject.setSimulated(false);
// need test equipment inserted
cacheObject.setEquipmentId(Long.valueOf(100));
cacheObject.setMinValue(new Float(23.3));
cacheObject.setMaxValue(new Float(12.2));
cacheObject.setAddress(new DataTagAddress());
cacheObject.setDataTagQuality(createValidQuality());
cacheObject.setCacheTimestamp(new Timestamp(System.currentTimeMillis()));
cacheObject.setDaqTimestamp(new Timestamp(System.currentTimeMillis()));
cacheObject.setSourceTimestamp(new Timestamp(System.currentTimeMillis()));
cacheObject.getAlarmIds().add(1L);
cacheObject.getAlarmIds().add(3L);
return cacheObject;
}
Aggregations