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