Search in sources :

Example 1 with DataTagAddress

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));
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) QueryKey(cern.c2mon.client.core.configuration.dynamic.query.QueryKey) HardwareAddressImpl(cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl) URI(java.net.URI) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) QueryObj(cern.c2mon.client.core.configuration.dynamic.query.QueryObj) Test(org.junit.jupiter.api.Test)

Example 2 with DataTagAddress

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);
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) QueryKey(cern.c2mon.client.core.configuration.dynamic.query.QueryKey) HardwareAddressImpl(cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl) URI(java.net.URI) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) QueryObj(cern.c2mon.client.core.configuration.dynamic.query.QueryObj) Test(org.junit.jupiter.api.Test)

Example 3 with DataTagAddress

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);
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) HashMap(java.util.HashMap) HardwareAddressImpl(cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 4 with DataTagAddress

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;
}
Also used : ValueUpdate(cern.c2mon.shared.common.datatag.ValueUpdate) ConfigurationController(cern.c2mon.daq.common.conf.core.ConfigurationController) ProcessConfiguration(cern.c2mon.shared.common.process.ProcessConfiguration) DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) SourceDataTag(cern.c2mon.shared.common.datatag.SourceDataTag) SourceCommandTag(cern.c2mon.shared.common.command.SourceCommandTag) EquipmentConfiguration(cern.c2mon.shared.common.process.EquipmentConfiguration)

Example 5 with DataTagAddress

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;
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) DataTagCacheObject(cern.c2mon.server.common.datatag.DataTagCacheObject) Timestamp(java.sql.Timestamp)

Aggregations

DataTagAddress (cern.c2mon.shared.common.datatag.DataTagAddress)46 Timestamp (java.sql.Timestamp)13 Test (org.junit.Test)12 Configuration (cern.c2mon.shared.client.configuration.api.Configuration)11 DataTagCacheObject (cern.c2mon.server.common.datatag.DataTagCacheObject)10 DataTag (cern.c2mon.shared.client.configuration.api.tag.DataTag)10 ContextConfiguration (org.springframework.test.context.ContextConfiguration)8 SourceDataTag (cern.c2mon.shared.common.datatag.SourceDataTag)7 Properties (java.util.Properties)7 ConfigurationDataTagUtil.buildCreateAllFieldsDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag)5 ConfigurationDataTagUtil.buildCreateBasicDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag)5 ControlTagCacheObject (cern.c2mon.server.common.control.ControlTagCacheObject)4 ConfigurationReport (cern.c2mon.shared.client.configuration.ConfigurationReport)4 Metadata (cern.c2mon.shared.client.metadata.Metadata)4 ConfigurationChangeEventReport (cern.c2mon.shared.daq.config.ConfigurationChangeEventReport)4 HashMap (java.util.HashMap)4 Metadata (cern.c2mon.server.common.metadata.Metadata)3 ConfigurationElement (cern.c2mon.shared.client.configuration.ConfigurationElement)3 SubEquipment (cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)3 Tag (cern.c2mon.shared.client.configuration.api.tag.Tag)3