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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations