Search in sources :

Example 1 with ConfigurationElement

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);
}
Also used : ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) Test(org.junit.Test)

Example 2 with ConfigurationElement

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);
}
Also used : ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RuleTagCacheObject(cern.c2mon.server.common.rule.RuleTagCacheObject) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with ConfigurationElement

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);
}
Also used : ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with ConfigurationElement

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);
}
Also used : CommandTag(cern.c2mon.shared.client.configuration.api.tag.CommandTag) ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) CommandTag(cern.c2mon.shared.client.configuration.api.tag.CommandTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) Test(org.junit.Test)

Example 5 with ConfigurationElement

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);
}
Also used : CommandTag(cern.c2mon.shared.client.configuration.api.tag.CommandTag) ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) CommandTag(cern.c2mon.shared.client.configuration.api.tag.CommandTag) Tag(cern.c2mon.shared.client.configuration.api.tag.Tag) Test(org.junit.Test)

Aggregations

ConfigurationElement (cern.c2mon.shared.client.configuration.ConfigurationElement)70 Test (org.junit.Test)61 Configuration (cern.c2mon.shared.client.configuration.api.Configuration)59 ContextConfiguration (org.springframework.test.context.ContextConfiguration)59 Properties (java.util.Properties)42 Tag (cern.c2mon.shared.client.configuration.api.tag.Tag)21 ConfigurationDataTagUtil.buildCreateAllFieldsDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateAllFieldsDataTag)14 ConfigurationDataTagUtil.buildCreateBasicDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag)14 DataTag (cern.c2mon.shared.client.configuration.api.tag.DataTag)14 Equipment (cern.c2mon.shared.client.configuration.api.equipment.Equipment)8 SubEquipment (cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)8 Process (cern.c2mon.shared.client.configuration.api.process.Process)8 CommandTag (cern.c2mon.shared.client.configuration.api.tag.CommandTag)8 RuleTag (cern.c2mon.shared.client.configuration.api.tag.RuleTag)8 Metadata (cern.c2mon.shared.client.metadata.Metadata)7 ConfigurationAlarmUtil.buildCreateAllFieldsAlarm (cern.c2mon.server.configuration.parser.util.ConfigurationAlarmUtil.buildCreateAllFieldsAlarm)5 ConfigurationAlarmUtil.buildCreateBasicAlarm (cern.c2mon.server.configuration.parser.util.ConfigurationAlarmUtil.buildCreateBasicAlarm)5 ConfigurationAlarmUtil.buildDeleteAlarm (cern.c2mon.server.configuration.parser.util.ConfigurationAlarmUtil.buildDeleteAlarm)5 Alarm (cern.c2mon.shared.client.configuration.api.alarm.Alarm)5 ConfigurationParseException (cern.c2mon.server.configuration.parser.exception.ConfigurationParseException)4