use of cern.c2mon.shared.client.configuration.ConfigurationElement in project c2mon by c2mon.
the class ConfigureRuleTagTest method updateNonExistentRuleTag.
@Test
public void updateNonExistentRuleTag() {
// setup Configuration:
RuleTag ruleTag = RuleTag.update(20L).description("The description").build();
List<Tag> tagUpdateList = Arrays.asList(ruleTag);
Configuration config = new Configuration(1L);
config.setEntities(tagUpdateList);
// setUp Mocks:
EasyMock.expect(tagFacade.isInTagCache(20L)).andReturn(false);
// run test
EasyMock.replay(tagFacade);
List<ConfigurationElement> result = parser.parse(config);
assertEquals(1, result.size());
assertEquals(ConfigConstants.Entity.MISSING, result.get(0).getEntity());
assertEquals(ConfigConstants.Status.WARNING, result.get(0).getStatus());
EasyMock.verify(tagFacade);
}
use of cern.c2mon.shared.client.configuration.ConfigurationElement in project c2mon by c2mon.
the class ConfigureRuleTagTest method updateRuleTagWithName.
@Test
public void updateRuleTagWithName() {
// setup Configuration:
Properties expectedProps = new Properties();
RuleTag ruleTag = buildUpdateRuleTagWithSomeFields("myRuleTag", expectedProps);
List<Tag> tagUpdateList = Arrays.asList(ruleTag);
Configuration config = new Configuration(1L);
config.setEntities(tagUpdateList);
// setUp Mocks:
EasyMock.expect(ruleTagCache.get("myRuleTag")).andReturn(new RuleTagCacheObject(20L));
EasyMock.expect(tagFacade.isInTagCache(20L)).andReturn(true);
EasyMock.replay(ruleTagCache, tagFacade);
List<ConfigurationElement> parsed = parser.parse(config);
assertEquals((long) parsed.get(0).getEntityId(), 20L);
assertEquals(parsed.get(0).getEntity(), ConfigConstants.Entity.RULETAG);
assertEquals(parsed.get(0).getAction(), ConfigConstants.Action.UPDATE);
assertEquals(parsed.get(0).getElementProperties(), expectedProps);
EasyMock.verify(ruleTagCache, tagFacade);
}
use of cern.c2mon.shared.client.configuration.ConfigurationElement in project c2mon by c2mon.
the class ConfigureRuleTagTest method updateRuleTagWithAllFields.
@Test
public void updateRuleTagWithAllFields() {
// setup Configuration:
Properties expectedProps = new Properties();
RuleTag ruleTag = buildUpdateRuleTagWithAllFields(100L, expectedProps);
List<Tag> tagUpdateList = Arrays.asList(ruleTag);
Configuration config = new Configuration(1L);
config.setEntities(tagUpdateList);
// setUp Mocks:
EasyMock.expect(tagFacade.isInTagCache(100L)).andReturn(true);
EasyMock.replay(tagFacade);
List<ConfigurationElement> parsed = parser.parse(config);
assertEquals((long) parsed.get(0).getEntityId(), 100L);
assertEquals(parsed.get(0).getEntity(), ConfigConstants.Entity.RULETAG);
assertEquals(parsed.get(0).getAction(), ConfigConstants.Action.UPDATE);
assertEquals(expectedProps, parsed.get(0).getElementProperties());
EasyMock.verify(tagFacade);
}
use of cern.c2mon.shared.client.configuration.ConfigurationElement in project c2mon by c2mon.
the class ConfigureCommandTagTest method updateCommandTagWithAllFields.
@Test
public void updateCommandTagWithAllFields() {
// setup Configuration:
Properties expectedProps = new Properties();
CommandTag tag = buildUpdateCommandTagWithAllFields(100L, expectedProps);
List<Tag> tagUpdateList = Collections.singletonList(tag);
Configuration config = new Configuration(1L);
config.setEntities(tagUpdateList);
// setUp Mocks:
EasyMock.expect(commandTagCache.hasKey(100L)).andReturn(true);
EasyMock.replay(commandTagCache);
List<ConfigurationElement> parsed = parser.parse(config);
assertEquals((long) parsed.get(0).getEntityId(), 100L);
assertEquals(parsed.get(0).getEntity(), ConfigConstants.Entity.COMMANDTAG);
assertEquals(parsed.get(0).getAction(), ConfigConstants.Action.UPDATE);
assertEquals(parsed.get(0).getElementProperties(), expectedProps);
EasyMock.verify(commandTagCache);
}
use of cern.c2mon.shared.client.configuration.ConfigurationElement in project c2mon by c2mon.
the class ConfigureCommandTagTest method deleteCommandTag.
@Test
public void deleteCommandTag() {
// setup Configuration:
CommandTag tag = buildDeleteCommandTag(20L);
List<Tag> tagUpdateList = Collections.singletonList(tag);
Configuration config = new Configuration(1L);
config.setEntities(tagUpdateList);
// setUp Mocks:
EasyMock.expect(commandTagCache.hasKey(20L)).andReturn(true);
EasyMock.replay(commandTagCache);
List<ConfigurationElement> parsed = parser.parse(config);
assertEquals(parsed.size(), 1);
assertEquals(parsed.get(0).getAction(), ConfigConstants.Action.REMOVE);
assertEquals(parsed.get(0).getEntity(), ConfigConstants.Entity.COMMANDTAG);
assertTrue(parsed.get(0).getElementProperties().isEmpty());
EasyMock.verify(commandTagCache);
}
Aggregations