Search in sources :

Example 1 with Metadata

use of cern.c2mon.shared.client.metadata.Metadata in project c2mon by c2mon.

the class TagImplTest method createValidTransferTag.

private TagUpdate createValidTransferTag(final Long tagId, Object value) {
    DataTagQuality tagQuality = new DataTagQualityImpl(TagQualityStatus.EQUIPMENT_DOWN, "its down!");
    Metadata metadata = new Metadata();
    metadata.addMetadata("testString", "hello");
    metadata.addMetadata("tesInt", 1);
    metadata.addMetadata("booleanFoo", true);
    metadata.addMetadata("tesLong", 1L);
    metadata.addMetadata("tesFloat", 1.0f);
    metadata.addMetadata("tesDouble", 1.0);
    tagQuality.addInvalidStatus(TagQualityStatus.EQUIPMENT_DOWN, "its down!");
    tagQuality.validate();
    TransferTagImpl tagUpdate = new TransferTagImpl(tagId, value, "test value desc", (DataTagQualityImpl) tagQuality, TagMode.TEST, new Timestamp(System.currentTimeMillis() - 10000L), new Timestamp(System.currentTimeMillis() - 5000L), new Timestamp(System.currentTimeMillis()), "Test description", "My.data.tag.name", "My.jms.topic");
    tagUpdate.setValueClassName(value != null ? value.getClass().getName() : null);
    tagUpdate.setMetadata(metadata.getMetadata());
    tagUpdate.addAlarmValue(createAlarmValue(tagId));
    tagUpdate.setUnit("kw");
    return tagUpdate;
}
Also used : DataTagQuality(cern.c2mon.shared.common.datatag.DataTagQuality) Metadata(cern.c2mon.shared.client.metadata.Metadata) DataTagQualityImpl(cern.c2mon.shared.common.datatag.DataTagQualityImpl) TransferTagImpl(cern.c2mon.shared.client.tag.TransferTagImpl) Timestamp(java.sql.Timestamp)

Example 2 with Metadata

use of cern.c2mon.shared.client.metadata.Metadata in project c2mon by c2mon.

the class TagImplTest method createAlarmValue.

/**
 * Private helper method for creating an <code>AlarmValueImpl</code>.
 */
private static AlarmValueImpl createAlarmValue(Long tagId) {
    Metadata metadata = new Metadata();
    metadata.addMetadata("testString", "hello");
    metadata.addMetadata("tesInt", 1);
    metadata.addMetadata("booleanFoo", true);
    metadata.addMetadata("tesLong", 1L);
    metadata.addMetadata("tesFloat", 1.0f);
    metadata.addMetadata("tesDouble", 1.0);
    AlarmValueImpl alarmValue = new AlarmValueImpl(4321L, 1007, "getFaultMember", "getFaultFamily", "getInfo", tagId, new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis() - 10), true);
    alarmValue.setMetadata(metadata.getMetadata());
    return alarmValue;
}
Also used : Metadata(cern.c2mon.shared.client.metadata.Metadata) AlarmValueImpl(cern.c2mon.shared.client.alarm.AlarmValueImpl) Timestamp(java.sql.Timestamp)

Example 3 with Metadata

use of cern.c2mon.shared.client.metadata.Metadata in project c2mon by c2mon.

the class ConfigurationCommandTagUtil method buildCreateAllFieldsCommandTag.

/**
 * Expected parent id is 10.
 */
public static CommandTag buildCreateAllFieldsCommandTag(Long id, Properties properties) {
    if (properties == null) {
        properties = new Properties();
    }
    CommandTag commandTag = CommandTag.create("CommandTag" + id, Integer.class, new SimpleHardwareAddressImpl("testAddress"), 30000, 6000, 200, 2, "RBAC class", "RBAC device", "RBAC property").id(id).equipmentId(10L).description("foo").mode(TagMode.OPERATIONAL).addMetadata("testMetadata", 11).maximum(100).minimum(0).build();
    properties.setProperty("name", "CommandTag" + id);
    properties.setProperty("description", "foo");
    properties.setProperty("mode", String.valueOf(TagMode.OPERATIONAL.ordinal()));
    properties.setProperty("dataType", Integer.class.getName());
    properties.setProperty("hardwareAddress", new SimpleHardwareAddressImpl("testAddress").toConfigXML());
    properties.setProperty("equipmentId", String.valueOf(10l));
    properties.setProperty("clientTimeout", String.valueOf(30000));
    properties.setProperty("execTimeout", String.valueOf(6000));
    properties.setProperty("sourceTimeout", String.valueOf(200));
    properties.setProperty("sourceRetries", String.valueOf(2));
    properties.setProperty("rbacClass", "RBAC class");
    properties.setProperty("rbacDevice", "RBAC device");
    properties.setProperty("rbacProperty", "RBAC property");
    properties.setProperty("maxValue", "100");
    properties.setProperty("minValue", "0");
    Metadata metadata = new Metadata();
    metadata.addMetadata("testMetadata", 11);
    properties.setProperty("metadata", Metadata.toJSON(metadata));
    return commandTag;
}
Also used : CommandTag(cern.c2mon.shared.client.configuration.api.tag.CommandTag) Metadata(cern.c2mon.shared.client.metadata.Metadata) SimpleHardwareAddressImpl(cern.c2mon.shared.common.datatag.address.impl.SimpleHardwareAddressImpl) Properties(java.util.Properties)

Example 4 with Metadata

use of cern.c2mon.shared.client.metadata.Metadata in project c2mon by c2mon.

the class ConfigureDataTagTest method updateDataTagSingleMetadata.

@Test
public void updateDataTagSingleMetadata() {
    DataTag dataTag = DataTag.update(100L).updateMetadata("testMetadata", 11).build();
    dataTag.setEquipmentId(10L);
    List<Tag> tagUpdateList = Arrays.asList(dataTag);
    Configuration config = new Configuration(1L);
    config.setEntities(tagUpdateList);
    Properties expectedProps = new Properties();
    expectedProps.setProperty("equipmentId", String.valueOf(10l));
    Metadata metadata = new Metadata();
    metadata.addMetadata("testMetadata", 11);
    metadata.setUpdate(true);
    expectedProps.setProperty("metadata", Metadata.toJSON(metadata));
    // setUp Mocks:
    EasyMock.expect(tagFacadeGateway.isInTagCache(100L)).andReturn(true);
    EasyMock.replay(tagFacadeGateway);
    List<ConfigurationElement> parsed = parser.parse(config);
    assertEquals(100L, (long) parsed.get(0).getEntityId());
    assertEquals(ConfigConstants.Entity.DATATAG, parsed.get(0).getEntity());
    assertEquals(ConfigConstants.Action.UPDATE, parsed.get(0).getAction());
    assertEquals(expectedProps.getProperty("metadata"), parsed.get(0).getElementProperties().getProperty("metadata"));
    EasyMock.verify(tagFacadeGateway);
}
Also used : ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Metadata(cern.c2mon.shared.client.metadata.Metadata) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) ConfigurationDataTagUtil.buildCreateBasicDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag) ConfigurationDataTagUtil.buildCreateAllFieldsDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag) Properties(java.util.Properties) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) ConfigurationDataTagUtil.buildCreateBasicDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag) ConfigurationDataTagUtil.buildCreateAllFieldsDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag) Test(org.junit.Test)

Example 5 with Metadata

use of cern.c2mon.shared.client.metadata.Metadata in project c2mon by c2mon.

the class ConfigureDataTagTest method createDataTagMultiMetadata.

@Test
public void createDataTagMultiMetadata() {
    DataTag dataTag = DataTag.create("DataTag", Integer.class, new DataTagAddress()).addMetadata("testMetadata1", 66).addMetadata("testMetadata1", 11).addMetadata("testMetadata2", 22).build();
    dataTag.setEquipmentId(10L);
    List<Tag> tagUpdateList = Arrays.asList(dataTag);
    Configuration config = new Configuration(1L);
    config.setEntities(tagUpdateList);
    Properties expectedProps = new Properties();
    expectedProps.setProperty("name", "DataTag");
    expectedProps.setProperty("description", "<no description provided>");
    expectedProps.setProperty("mode", String.valueOf(TagMode.OPERATIONAL.ordinal()));
    expectedProps.setProperty("dataType", Integer.class.getName());
    expectedProps.setProperty("isLogged", String.valueOf(true));
    expectedProps.setProperty("equipmentId", String.valueOf(10L));
    expectedProps.setProperty("address", new DataTagAddress().toConfigXML());
    Metadata metadata = new Metadata();
    metadata.addMetadata("testMetadata1", 11);
    metadata.addMetadata("testMetadata2", 22);
    expectedProps.setProperty("metadata", Metadata.toJSON(metadata));
    // setUp Mocks:
    EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true);
    EasyMock.expect(sequenceDAO.getNextTagId()).andReturn(100L);
    EasyMock.expect(tagFacadeGateway.isInTagCache(100L)).andReturn(false);
    EasyMock.replay(equipmentCache, sequenceDAO, tagFacadeGateway);
    List<ConfigurationElement> parsed = parser.parse(config);
    assertEquals(parsed.size(), 1);
    assertEquals((long) parsed.get(0).getEntityId(), 100L);
    assertTrue(parsed.get(0).getEntity().equals(ConfigConstants.Entity.DATATAG));
    assertTrue(parsed.get(0).getAction().equals(ConfigConstants.Action.CREATE));
    assertEquals(expectedProps.getProperty("metadata"), parsed.get(0).getElementProperties().getProperty("metadata"));
    EasyMock.verify(equipmentCache, sequenceDAO, tagFacadeGateway);
}
Also used : DataTagAddress(cern.c2mon.shared.common.datatag.DataTagAddress) ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Metadata(cern.c2mon.shared.client.metadata.Metadata) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) ConfigurationDataTagUtil.buildCreateBasicDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag) ConfigurationDataTagUtil.buildCreateAllFieldsDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag) Properties(java.util.Properties) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) ConfigurationDataTagUtil.buildCreateBasicDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag) ConfigurationDataTagUtil.buildCreateAllFieldsDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag) Test(org.junit.Test)

Aggregations

Metadata (cern.c2mon.shared.client.metadata.Metadata)15 Properties (java.util.Properties)13 DataTag (cern.c2mon.shared.client.configuration.api.tag.DataTag)8 ConfigurationDataTagUtil.buildCreateAllFieldsDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag)7 ConfigurationDataTagUtil.buildCreateBasicDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag)7 ConfigurationElement (cern.c2mon.shared.client.configuration.ConfigurationElement)7 Configuration (cern.c2mon.shared.client.configuration.api.Configuration)7 Tag (cern.c2mon.shared.client.configuration.api.tag.Tag)7 Test (org.junit.Test)7 ContextConfiguration (org.springframework.test.context.ContextConfiguration)7 DataTagAddress (cern.c2mon.shared.common.datatag.DataTagAddress)4 ValueAlarmCondition (cern.c2mon.shared.client.alarm.condition.ValueAlarmCondition)2 Alarm (cern.c2mon.shared.client.configuration.api.alarm.Alarm)2 RuleTag (cern.c2mon.shared.client.configuration.api.tag.RuleTag)2 Timestamp (java.sql.Timestamp)2 AlarmValueImpl (cern.c2mon.shared.client.alarm.AlarmValueImpl)1 CommandTag (cern.c2mon.shared.client.configuration.api.tag.CommandTag)1 TransferTagImpl (cern.c2mon.shared.client.tag.TransferTagImpl)1 DataTagQuality (cern.c2mon.shared.common.datatag.DataTagQuality)1 DataTagQualityImpl (cern.c2mon.shared.common.datatag.DataTagQualityImpl)1