From 8cd59d41ad92cdfeb046847700bc2beb07862207 Mon Sep 17 00:00:00 2001 From: Lars Johansson <lars.johansson@ess.eu> Date: Tue, 15 Mar 2022 17:07:38 +0100 Subject: [PATCH] Change validation for structure to allow one pending entry Allow one pending entry for uuid, mnemonic, mnemonic equivalence. Update validation to consider status together with mnemonic, mnemonic validation. Multiple pending entries per uuid no longer allowed. Update docker integration tests accordingly. --- .../openepics/names/util/ValidateUtil.java | 300 ++++++++++++------ .../names/docker/StructuresDeviceGroupIT.java | 21 ++ .../names/docker/StructuresDeviceTypeIT.java | 21 ++ .../names/docker/StructuresDisciplineIT.java | 21 ++ .../names/docker/StructuresSubsystemIT.java | 21 ++ .../names/docker/StructuresSystemGroupIT.java | 21 ++ .../names/docker/StructuresSystemIT.java | 21 ++ 7 files changed, 328 insertions(+), 98 deletions(-) diff --git a/src/main/java/org/openepics/names/util/ValidateUtil.java b/src/main/java/org/openepics/names/util/ValidateUtil.java index 67398bff..d6c9a92c 100644 --- a/src/main/java/org/openepics/names/util/ValidateUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateUtil.java @@ -908,9 +908,9 @@ public class ValidateUtil { public static void validateStructureElementDataInItself(StructureElement structureElement, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder, StructureChoice structureChoice) { // check structure element data in itself // update, delete - // uuid - approved, latest, not deleted - list size 1 - // possibly + // definitely (not possibly) // no pending entry waiting to be approved, cancelled, rejected (pending with higher id than currently approved) + // uuid - approved, latest, not deleted - list size 1 // approve, reject, cancel // uuid - pending, latest, not deleted - list size 1 @@ -920,55 +920,85 @@ public class ValidateUtil { if (StructureChoice.UPDATE.equals(structureChoice) || StructureChoice.DELETE.equals(structureChoice)) { if (Type.SYSTEMGROUP.equals(structureElement.getType())) { - List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<SystemGroup> systemGroups = null; + + // status, uuid + // status, not deleted, uuid + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.SYSTEM.equals(structureElement.getType())) { - List<System> systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<System> systems = null; + + // status, uuid + // status, not deleted, uuid + systems = holderRepositories.getSystemRepository().readSystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(systems != null && systems.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.SUBSYSTEM.equals(structureElement.getType())) { - List<Subsystem> subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(subsystems != null && subsystems.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<Subsystem> subsystems = null; + + // status, uuid + // status, not deleted, uuid + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(subsystems != null && subsystems.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(subsystems != null && subsystems.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DISCIPLINE.equals(structureElement.getType())) { - List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<Discipline> disciplines = null; + + // status, uuid + // status, not deleted, uuid + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DEVICEGROUP.equals(structureElement.getType())) { - List<DeviceGroup> deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<DeviceGroup> deviceGroups = null; + + // status, uuid + // status, not deleted, uuid + deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - List<DeviceType> deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(deviceTypes != null && deviceTypes.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + List<DeviceType> deviceTypes = null; + + // status, uuid + // status, not deleted, uuid + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(deviceTypes != null && deviceTypes.size() == 0, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.APPROVED, false, FieldStructure.UUID, structureElement.getUuid().toString()); + ValidateUtil.validateCondition(deviceTypes != null && deviceTypes.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } } else if (StructureChoice.APPROVE.equals(structureChoice) || StructureChoice.CANCEL.equals(structureChoice) || StructureChoice.REJECT.equals(structureChoice)) { if (Type.SYSTEMGROUP.equals(structureElement.getType())) { + // status, uuid List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.SYSTEM.equals(structureElement.getType())) { + // status, uuid List<System> systems = holderRepositories.getSystemRepository().readSystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.SUBSYSTEM.equals(structureElement.getType())) { + // status, uuid List<Subsystem> subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(subsystems != null && subsystems.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(subsystems != null && subsystems.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DISCIPLINE.equals(structureElement.getType())) { + // status, uuid List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DEVICEGROUP.equals(structureElement.getType())) { + // status, uuid List<DeviceGroup> deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { + // status, uuid List<DeviceType> deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); - ValidateUtil.validateCondition(deviceTypes != null && deviceTypes.size() == 1, HttpStatus.BAD_REQUEST, - ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); + ValidateUtil.validateCondition(deviceTypes != null && deviceTypes.size() == 1, HttpStatus.BAD_REQUEST, ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, structureElement.toString()); } } } @@ -1007,68 +1037,103 @@ public class ValidateUtil { if (Type.SYSTEMGROUP.equals(structureElement.getType())) { // note rules for mnemonic for system group if (!StringUtils.isEmpty(structureElement.getMnemonic())) { - // mnemonic + List<SystemGroup> systemGroups = null; String message = ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); + + // status, mnemonic + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, false, FieldStructure.MNEMONICEQUIVALENCE, namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); } } else if (Type.SYSTEM.equals(structureElement.getType())) { - // parent uuid - String message = ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); + List<SystemGroup> systemGroups = null; + List<System> systems = null; + String message = null; + + // status, parent + message = ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent - // mnemonic + // status, parent, mnemonic message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<System> systems = holderRepositories.getSystemRepository().readSystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systemGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + systems = holderRepositories.getSystemRepository().readSystems(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systemGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); + systems = holderRepositories.getSystemRepository().readSystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systemGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); - // parent - // mnemonic equivalence + // status, parent, mnemonic equivalence + systems = holderRepositories.getSystemRepository().readSystems(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {systemGroups.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); systems = holderRepositories.getSystemRepository().readSystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {systemGroups.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.SUBSYSTEM.equals(structureElement.getType())) { - // parent uuid - String message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<System> systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); + List<System> systems = null; + List<Subsystem> subsystems = null; + String message = null; + + // status, parent + message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent - // mnemonic + // status, parent, mnemonic message = ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Subsystem> subsystems = holderRepositories.getSubsystemRepository().readSubsystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systems.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systems.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {systems.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); - // parent - // mnemonic equivalence + // status. parent, mnemonic equivalence + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {systems.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); subsystems = holderRepositories.getSubsystemRepository().readSubsystems(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {systems.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DISCIPLINE.equals(structureElement.getType())) { - // mnemonic + List<Discipline> disciplines = null; String message = ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); + + // status, mnemonic + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONIC, structureElement.getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, false, FieldStructure.MNEMONICEQUIVALENCE, namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DEVICEGROUP.equals(structureElement.getType())) { - // parent uuid - String message = ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); + List<Discipline> disciplines = null; + String message = null; + + // status, parent + message = ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, message, details); // note rules for mnemonic for device group @@ -1077,101 +1142,134 @@ public class ValidateUtil { message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; ValidateUtil.validateCondition(StringUtils.isEmpty(structureElement.getMnemonic()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - // parent uuid - String message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceGroup> deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); + List<DeviceGroup> deviceGroups = null; + List<DeviceType> deviceTypes = null; + String message = null; + + // status, parent + message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, structureElement.getParent().toString()); ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent - // mnemonic + // status, parent, mnemonic message = ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceType> deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {deviceGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {deviceGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONIC}, new String[] {deviceGroups.get(0).getUuid().toString(), structureElement.getMnemonic()}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, parent, mnemonic equivalence + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(new Status[] {Status.PENDING}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {deviceGroups.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); + validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); + validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(new Status[] {Status.APPROVED}, false, new FieldStructure[] {FieldStructure.PARENT, FieldStructure.MNEMONICEQUIVALENCE}, new String[] {deviceGroups.get(0).getUuid().toString(), namingConvention.equivalenceClassRepresentative(structureElement.getMnemonic())}, null, null, null, null); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(structureElement.getUuid()), HttpStatus.BAD_REQUEST, message, details); } } else if (StructureChoice.APPROVE.equals(structureChoice)) { - // if (Type.SYSTEMGROUP.equals(structureElement.getType())) { + List<SystemGroup> toBeApproved = null; + List<SystemGroup> systemGroups = null; String message = ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<SystemGroup> toBeApproved = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + + // to be approved - status, uuid + toBeApproved = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // mnemonic - List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); + // status, mnemonic + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, toBeApproved.get(0).getMnemonicEquivalence()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systemGroups == null || systemGroups.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systemGroups == null || systemGroups.isEmpty() || systemGroups.size() == 1 && systemGroups.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.SYSTEM.equals(structureElement.getType())) { - String message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<System> toBeApproved = holderRepositories.getSystemRepository().readSystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + List<SystemGroup> systemGroups = null; + List<System> toBeApproved = null; + List<System> systems = null; + String message = null; + + // to be approved - status, uuid + message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + toBeApproved = holderRepositories.getSystemRepository().readSystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent uuid + // status, parent message = ValidateUtil.SYSTEMGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<SystemGroup> systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); + systemGroups = holderRepositories.getSystemGroupRepository().readSystemGroups(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); ValidateUtil.validateCondition(systemGroups != null && systemGroups.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // mnemonic + // status, mnemonic message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<System> systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); + systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, toBeApproved.get(0).getMnemonicEquivalence()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, systems == null || systems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, systems == null || systems.isEmpty() || systems.size() == 1 && systems.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.SUBSYSTEM.equals(structureElement.getType())) { - String message = ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Subsystem> toBeApproved = holderRepositories.getSubsystemRepository().readSubsystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + List<System> systems = null; + List<Subsystem> toBeApproved = null; + List<Subsystem> subsystems = null; + String message = null; + + // to be approved - status, uuid + message = ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + toBeApproved = holderRepositories.getSubsystemRepository().readSubsystems(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent uuid + // status, parent message = ValidateUtil.SYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<System> systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); + systems = holderRepositories.getSystemRepository().readSystems(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); ValidateUtil.validateCondition(systems != null && systems.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // mnemonic + // status, mnemonic message = ValidateUtil.SUBSYSTEM + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Subsystem> subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); + subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence subsystems = holderRepositories.getSubsystemRepository().readSubsystems(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, toBeApproved.get(0).getMnemonicEquivalence()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, subsystems == null || subsystems.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, subsystems == null || subsystems.isEmpty() || subsystems.size() == 1 && subsystems.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DISCIPLINE.equals(structureElement.getType())) { + List<Discipline> toBeApproved = null; + List<Discipline> disciplines = null; String message = ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Discipline> toBeApproved = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + + // to be approved - status, uuid + toBeApproved = holderRepositories.getDisciplineRepository().readDisciplines(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // mnemonic - List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); + // status, mnemonic + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, toBeApproved.get(0).getMnemonicEquivalence()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, disciplines == null || disciplines.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, disciplines == null || disciplines.isEmpty() || disciplines.size() == 1 && disciplines.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DEVICEGROUP.equals(structureElement.getType())) { - String message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceGroup> toBeApproved = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + List<Discipline> disciplines = null; + List<DeviceGroup> toBeApproved = null; + String message = null; + + // to be approved - status, uuid + message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + toBeApproved = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent uuid + // status, parent message = ValidateUtil.DISCIPLINE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<Discipline> disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); + disciplines = holderRepositories.getDisciplineRepository().readDisciplines(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); ValidateUtil.validateCondition(disciplines != null && disciplines.size() == 1, HttpStatus.BAD_REQUEST, message, details); // note rules for mnemonic for device group @@ -1180,22 +1278,28 @@ public class ValidateUtil { message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; ValidateUtil.validateCondition(StringUtils.isEmpty(structureElement.getMnemonic()), HttpStatus.BAD_REQUEST, message, details); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - String message = ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceType> toBeApproved = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); + List<DeviceGroup> deviceGroups = null; + List<DeviceType> toBeApproved = null; + List<DeviceType> deviceTypes = null; + String message = null; + + // to be approved - status, uuid + message = ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; + toBeApproved = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.PENDING, null, FieldStructure.UUID, structureElement.getUuid().toString()); ValidateUtil.validateCondition(toBeApproved != null && toBeApproved.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // parent uuid + // status, parent message = ValidateUtil.DEVICEGROUP + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceGroup> deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); + deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(Status.APPROVED, false, FieldStructure.UUID, toBeApproved.get(0).getParentUuid().toString()); ValidateUtil.validateCondition(deviceGroups != null && deviceGroups.size() == 1, HttpStatus.BAD_REQUEST, message, details); - // mnemonic + // status, mnemonic message = ValidateUtil.DEVICETYPE + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT; - List<DeviceType> deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); + deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.APPROVED, false, FieldStructure.MNEMONIC, toBeApproved.get(0).getMnemonic()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); - // mnemonic equivalence + // status, mnemonic equivalence deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(Status.APPROVED, false, FieldStructure.MNEMONICEQUIVALENCE, toBeApproved.get(0).getMnemonicEquivalence()); validateConditionIfStructureChoice(StructureChoice.CREATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty(), HttpStatus.BAD_REQUEST, message, details); validateConditionIfStructureChoice(StructureChoice.UPDATE, structureChoice, deviceTypes == null || deviceTypes.isEmpty() || deviceTypes.size() == 1 && deviceTypes.get(0).getUuid().equals(toBeApproved.get(0).getUuid()), HttpStatus.BAD_REQUEST, message, details); diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java index c72d809a..ad2b1244 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java @@ -326,18 +326,21 @@ public class StructuresDeviceGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -369,18 +372,21 @@ public class StructuresDeviceGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -412,18 +418,21 @@ public class StructuresDeviceGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -554,11 +563,13 @@ public class StructuresDeviceGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -607,12 +618,14 @@ public class StructuresDeviceGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -661,12 +674,14 @@ public class StructuresDeviceGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -798,11 +813,13 @@ public class StructuresDeviceGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -851,12 +868,14 @@ public class StructuresDeviceGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -905,12 +924,14 @@ public class StructuresDeviceGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java index 4510bab1..a77d8082 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java @@ -337,18 +337,21 @@ public class StructuresDeviceTypeIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -380,18 +383,21 @@ public class StructuresDeviceTypeIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -423,18 +429,21 @@ public class StructuresDeviceTypeIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -565,11 +574,13 @@ public class StructuresDeviceTypeIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -618,12 +629,14 @@ public class StructuresDeviceTypeIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -672,12 +685,14 @@ public class StructuresDeviceTypeIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -809,11 +824,13 @@ public class StructuresDeviceTypeIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -862,12 +879,14 @@ public class StructuresDeviceTypeIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -916,12 +935,14 @@ public class StructuresDeviceTypeIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); diff --git a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java index 2526cd0f..cee8f416 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java @@ -293,18 +293,21 @@ public class StructuresDisciplineIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -336,18 +339,21 @@ public class StructuresDisciplineIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -379,18 +385,21 @@ public class StructuresDisciplineIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -515,11 +524,13 @@ public class StructuresDisciplineIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -568,12 +579,14 @@ public class StructuresDisciplineIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -622,12 +635,14 @@ public class StructuresDisciplineIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -753,11 +768,13 @@ public class StructuresDisciplineIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -806,12 +823,14 @@ public class StructuresDisciplineIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -860,12 +879,14 @@ public class StructuresDisciplineIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); diff --git a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java index c5b450e8..0c7a15ed 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java @@ -353,18 +353,21 @@ public class StructuresSubsystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -396,18 +399,21 @@ public class StructuresSubsystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -439,18 +445,21 @@ public class StructuresSubsystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -581,11 +590,13 @@ public class StructuresSubsystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -634,12 +645,14 @@ public class StructuresSubsystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -688,12 +701,14 @@ public class StructuresSubsystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -825,11 +840,13 @@ public class StructuresSubsystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -878,12 +895,14 @@ public class StructuresSubsystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -932,12 +951,14 @@ public class StructuresSubsystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java index d9ac91fd..b38a0731 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java @@ -313,6 +313,7 @@ public class StructuresSystemGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create @@ -320,12 +321,14 @@ public class StructuresSystemGroupIT { structureElement = createdStructureElement; uuid = createdStructureElement.getUuid(); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create @@ -379,18 +382,21 @@ public class StructuresSystemGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -422,18 +428,21 @@ public class StructuresSystemGroupIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -559,11 +568,13 @@ public class StructuresSystemGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -613,12 +624,14 @@ public class StructuresSystemGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -668,12 +681,14 @@ public class StructuresSystemGroupIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -799,11 +814,13 @@ public class StructuresSystemGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -852,12 +869,14 @@ public class StructuresSystemGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -906,12 +925,14 @@ public class StructuresSystemGroupIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java index 4d1425c8..cf24c536 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java @@ -338,18 +338,21 @@ public class StructuresSystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); structureElement = approvedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -381,18 +384,21 @@ public class StructuresSystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -424,18 +430,21 @@ public class StructuresSystemIT { "description", Status.PENDING, Boolean.FALSE, Boolean.FALSE, null, "test who", "comment"); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); // create createdStructureElement = ITUtilStructureElement.assertCreate(structureElement); structureElement = createdStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -566,11 +575,13 @@ public class StructuresSystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -619,12 +630,14 @@ public class StructuresSystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -673,12 +686,14 @@ public class StructuresSystemIT { updatedStructureElement = ITUtilStructureElement.assertUpdate(structureElement); structureElement = updatedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.UPDATE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); @@ -810,11 +825,13 @@ public class StructuresSystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.TRUE); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.APPROVE, Boolean.FALSE); } catch (Exception e) { fail(); @@ -863,12 +880,14 @@ public class StructuresSystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.TRUE); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); structureElement = cancelledStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CANCEL, Boolean.FALSE); } catch (Exception e) { fail(); @@ -917,12 +936,14 @@ public class StructuresSystemIT { deletedStructureElement = ITUtilStructureElement.assertDelete(structureElement); structureElement = deletedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.FALSE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.TRUE); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); structureElement = rejectedStructureElement; + ITUtilStructureElement.assertValidate(structureElement, StructureChoice.DELETE, Boolean.TRUE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.REJECT, Boolean.FALSE); } catch (Exception e) { fail(); -- GitLab