Search in sources :

Example 1 with QueryObj

use of cern.c2mon.client.core.configuration.dynamic.query.QueryObj 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 QueryObj

use of cern.c2mon.client.core.configuration.dynamic.query.QueryObj in project c2mon by c2mon.

the class QueryObjTest method createQueryObjWithMissingKeyShouldThrowException.

@Test
void createQueryObjWithMissingKeyShouldThrowException() {
    List<QueryKey<?>> key = Collections.singletonList(new QueryKey<Integer>("missing", null, true));
    assertThrows(DynConfigException.class, () -> new QueryObj(uri, key));
}
Also used : QueryKey(cern.c2mon.client.core.configuration.dynamic.query.QueryKey) QueryObj(cern.c2mon.client.core.configuration.dynamic.query.QueryObj) Test(org.junit.jupiter.api.Test)

Example 3 with QueryObj

use of cern.c2mon.client.core.configuration.dynamic.query.QueryObj in project c2mon by c2mon.

the class QueryObjTest method getUriWithoutParamsShouldReturnUri.

@Test
void getUriWithoutParamsShouldReturnUri() throws DynConfigException {
    queryObj = new QueryObj(uri, Collections.emptyList());
    assertEquals("opc.tcp://host:500/path", queryObj.getUriWithoutParams());
}
Also used : QueryObj(cern.c2mon.client.core.configuration.dynamic.query.QueryObj) Test(org.junit.jupiter.api.Test)

Example 4 with QueryObj

use of cern.c2mon.client.core.configuration.dynamic.query.QueryObj 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 5 with QueryObj

use of cern.c2mon.client.core.configuration.dynamic.query.QueryObj in project c2mon by c2mon.

the class TagConfigStrategyTest method assertQueryAndStrategyMatch.

void assertQueryAndStrategyMatch(String regex) throws DynConfigException {
    URI uri = URI.create("dip://host/path?publicationName=x1");
    QueryObj queryObj = new QueryObj(uri, Collections.emptyList());
    strategy = ITagConfigStrategy.of(uri);
    assertEquals(queryObj.matches(regex), strategy.matches(regex));
}
Also used : URI(java.net.URI) QueryObj(cern.c2mon.client.core.configuration.dynamic.query.QueryObj)

Aggregations

QueryObj (cern.c2mon.client.core.configuration.dynamic.query.QueryObj)9 Test (org.junit.jupiter.api.Test)7 QueryKey (cern.c2mon.client.core.configuration.dynamic.query.QueryKey)5 URI (java.net.URI)4 DataTag (cern.c2mon.shared.client.configuration.api.tag.DataTag)2 DataTagAddress (cern.c2mon.shared.common.datatag.DataTagAddress)2 HardwareAddressImpl (cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl)2 IQueryObj (cern.c2mon.client.core.configuration.dynamic.query.IQueryObj)1