Search in sources :

Example 1 with SubEquipment

use of cern.c2mon.shared.client.configuration.api.equipment.SubEquipment in project c2mon by c2mon.

the class SubEquipmentConfigurationManagerImpl method createSubEquipment.

@Override
public ConfigurationReport createSubEquipment(String equipmentName, List<SubEquipment> subEquipments) {
    // validate configuration
    validateIsCreate(subEquipments);
    // Set parent Ids to the configuration
    for (SubEquipment equipment : subEquipments) {
        equipment.setParentEquipmentName(equipmentName);
    }
    // set fields for the server
    Configuration config = new Configuration();
    config.setEntities(subEquipments);
    return configurationRequestSender.applyConfiguration(config, null);
}
Also used : Configuration(cern.c2mon.shared.client.configuration.api.Configuration) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)

Example 2 with SubEquipment

use of cern.c2mon.shared.client.configuration.api.equipment.SubEquipment in project c2mon by c2mon.

the class SubEquipmentConfigurationManagerImpl method removeSubEquipment.

@Override
public ConfigurationReport removeSubEquipment(Set<String> subEquipmentNames) {
    List<SubEquipment> equipmentsToDelete = new ArrayList<>();
    for (String equipmentName : subEquipmentNames) {
        SubEquipment deleteSubEquipment = new SubEquipment();
        deleteSubEquipment.setName(equipmentName);
        deleteSubEquipment.setDeleted(true);
        equipmentsToDelete.add(deleteSubEquipment);
    }
    Configuration config = new Configuration();
    config.setEntities(equipmentsToDelete);
    return configurationRequestSender.applyConfiguration(config, null);
}
Also used : Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ArrayList(java.util.ArrayList) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)

Example 3 with SubEquipment

use of cern.c2mon.shared.client.configuration.api.equipment.SubEquipment in project c2mon by c2mon.

the class ParseToJSON method parseComplexConfiguration2.

@Test
public void parseComplexConfiguration2() {
    Process process = buildCreateBasicProcess(null);
    Equipment equipment = buildCreateBasicEquipment(null);
    SubEquipment subEquipment = buildCreateBasicSubEquipment(null);
    DataTag dataTag = buildCreateBasicDataTag(null);
    Alarm alarm = buildCreateBasicAlarm(null);
    RuleTag ruleTag = buildCreateBasicRuleTag(null);
    List<ConfigurationEntity> entities = Arrays.asList(process, equipment, subEquipment, dataTag, alarm, ruleTag);
    Configuration insert = new Configuration();
    insert.setEntities(entities);
    Configuration confRead = serializeDeserializeConfiguration(insert);
    assertEquals(insert, confRead);
}
Also used : ConfigurationEquipmentUtil.buildCreateBasicEquipment(cern.c2mon.server.configuration.parser.util.ConfigurationEquipmentUtil.buildCreateBasicEquipment) Equipment(cern.c2mon.shared.client.configuration.api.equipment.Equipment) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment) ConfigurationSubEquipmentUtil.buildCreateBasicSubEquipment(cern.c2mon.server.configuration.parser.util.ConfigurationSubEquipmentUtil.buildCreateBasicSubEquipment) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ConfigurationEntity(cern.c2mon.shared.client.configuration.api.util.ConfigurationEntity) Alarm(cern.c2mon.shared.client.configuration.api.alarm.Alarm) ConfigurationAlarmUtil.buildCreateBasicAlarm(cern.c2mon.server.configuration.parser.util.ConfigurationAlarmUtil.buildCreateBasicAlarm) RuleTag(cern.c2mon.shared.client.configuration.api.tag.RuleTag) ConfigurationRuleTagUtil.buildCreateBasicRuleTag(cern.c2mon.server.configuration.parser.util.ConfigurationRuleTagUtil.buildCreateBasicRuleTag) ConfigurationProcessUtil.buildCreateBasicProcess(cern.c2mon.server.configuration.parser.util.ConfigurationProcessUtil.buildCreateBasicProcess) Process(cern.c2mon.shared.client.configuration.api.process.Process) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment) ConfigurationSubEquipmentUtil.buildCreateBasicSubEquipment(cern.c2mon.server.configuration.parser.util.ConfigurationSubEquipmentUtil.buildCreateBasicSubEquipment) DataTag(cern.c2mon.shared.client.configuration.api.tag.DataTag) ConfigurationDataTagUtil.buildCreateBasicDataTag(cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag) Test(org.junit.Test)

Example 4 with SubEquipment

use of cern.c2mon.shared.client.configuration.api.equipment.SubEquipment in project c2mon by c2mon.

the class ConfigureSubEquipmentTest method updateSubEquipmentWithId.

@Test
public void updateSubEquipmentWithId() {
    // setup Configuration:
    Properties expectedProps = new Properties();
    SubEquipment equipment = buildUpdateSubEquipmentWithSomeFields(10L, expectedProps);
    List<SubEquipment> equipmentUpdateList = Arrays.asList(equipment);
    Configuration config = new Configuration(1L);
    config.setEntities(equipmentUpdateList);
    // setUp Mocks:
    EasyMock.expect(subEquipmentCache.hasKey(10L)).andReturn(true);
    EasyMock.replay(subEquipmentCache);
    List<ConfigurationElement> parsed = parser.parse(config);
    assertEquals((long) parsed.get(0).getEntityId(), 10L);
    assertEquals(parsed.get(0).getEntity(), ConfigConstants.Entity.SUBEQUIPMENT);
    assertEquals(parsed.get(0).getAction(), ConfigConstants.Action.UPDATE);
    assertEquals(parsed.get(0).getElementProperties(), expectedProps);
    EasyMock.verify(subEquipmentCache);
}
Also used : ConfigurationElement(cern.c2mon.shared.client.configuration.ConfigurationElement) Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with SubEquipment

use of cern.c2mon.shared.client.configuration.api.equipment.SubEquipment in project c2mon by c2mon.

the class ConfigureSubEquipmentTest method createSubEquipmentWithNonExistentProcess.

@Test
public void createSubEquipmentWithNonExistentProcess() {
    // Setup Exception
    tagException.expect(ConfigurationParseException.class);
    SubEquipment subEquipment = SubEquipment.create("myEquipment").id(10L).build();
    subEquipment.setEquipmentId(1L);
    List<SubEquipment> subEquipmentList = Arrays.asList(subEquipment);
    Configuration config = new Configuration(1L);
    config.setEntities(subEquipmentList);
    // setUp Mocks:
    EasyMock.expect(equipmentCache.hasKey(1L)).andReturn(false);
    // run test
    EasyMock.replay(equipmentCache);
    parser.parse(config);
    EasyMock.verify(equipmentCache);
}
Also used : Configuration(cern.c2mon.shared.client.configuration.api.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) SubEquipment(cern.c2mon.shared.client.configuration.api.equipment.SubEquipment) Test(org.junit.Test)

Aggregations

SubEquipment (cern.c2mon.shared.client.configuration.api.equipment.SubEquipment)24 Configuration (cern.c2mon.shared.client.configuration.api.Configuration)18 ContextConfiguration (org.springframework.test.context.ContextConfiguration)13 Properties (java.util.Properties)12 Test (org.junit.Test)12 ConfigurationElement (cern.c2mon.shared.client.configuration.ConfigurationElement)8 DataTagAddress (cern.c2mon.shared.common.datatag.DataTagAddress)3 SubEquipmentCacheObject (cern.c2mon.server.common.subequipment.SubEquipmentCacheObject)2 ConfigurationReport (cern.c2mon.shared.client.configuration.ConfigurationReport)2 Change (cern.c2mon.shared.daq.config.Change)2 ChangeReport (cern.c2mon.shared.daq.config.ChangeReport)2 ConfigurationChangeEventReport (cern.c2mon.shared.daq.config.ConfigurationChangeEventReport)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ConfigurationAlarmUtil.buildCreateBasicAlarm (cern.c2mon.server.configuration.parser.util.ConfigurationAlarmUtil.buildCreateBasicAlarm)1 ConfigurationDataTagUtil.buildCreateBasicDataTag (cern.c2mon.server.configuration.parser.util.ConfigurationDataTagUtil.buildCreateBasicDataTag)1 ConfigurationEquipmentUtil.buildCreateBasicEquipment (cern.c2mon.server.configuration.parser.util.ConfigurationEquipmentUtil.buildCreateBasicEquipment)1 ConfigurationProcessUtil.buildCreateBasicProcess (cern.c2mon.server.configuration.parser.util.ConfigurationProcessUtil.buildCreateBasicProcess)1 ConfigurationRuleTagUtil.buildCreateBasicRuleTag (cern.c2mon.server.configuration.parser.util.ConfigurationRuleTagUtil.buildCreateBasicRuleTag)1