Skip to content

Commit

Permalink
Removed entityNotAllowedToSendCard attribute #5614
Browse files Browse the repository at this point in the history
Signed-off-by: ClementBouvierN <clement.bouvierneveu@rte-france.com>
  • Loading branch information
ClementBouvierN authored and freddidierRTE committed Jan 11, 2024
1 parent f41ba11 commit 592b305
Show file tree
Hide file tree
Showing 30 changed files with 132 additions and 160 deletions.
4 changes: 0 additions & 4 deletions config/docker/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ operatorfabric.users.default:
name: French Control Centers
description: French Control Centers
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
entityAllowedToSendCard: false
- id: EUROPEAN_SUPERVISION_CENTERS
name: European Supervision Centers
description: European Supervision Centers
entityAllowedToSendCard: false
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
- id: IT_SUPERVISOR_ENTITY
name: IT SUPERVISION CENTER
Expand All @@ -143,7 +141,6 @@ operatorfabric.users.default:
- id: ENTITY_IT
name: Italian Control Centers
description: Italian Control Centers
entityAllowedToSendCard: false
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
- id: ENTITY1_NL
name: Control Center NL North
Expand All @@ -158,7 +155,6 @@ operatorfabric.users.default:
- id: ENTITY_NL
name: Dutch Control Centers
description: Dutch Control Centers
entityAllowedToSendCard: false
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
- id: ENTITY1_EU
name: North Europe Control Center
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2018-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2018-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -41,20 +41,15 @@ public class EntityData implements Entity {
private String name;
private String description;
private Set<String> labels;

@Builder.Default
private Boolean entityAllowedToSendCard = true;

private Set<String> parents;
private Set<RolesEnum> roles;

public EntityData(EntityData entityData) {
this.id = entityData.id;
this.name = entityData.name;
this.description = entityData.description;
if (entityData.labels==null) this.labels = new HashSet<>();
else this.labels = new HashSet<>(entityData.labels);
this.entityAllowedToSendCard = entityData.entityAllowedToSendCard;
if (entityData.parents==null) this.parents = new HashSet<>();
else this.parents = new HashSet<>(entityData.parents);
if (entityData.roles==null) this.roles = new HashSet<>();
Expand All @@ -67,7 +62,6 @@ public EntityData(Entity entity) {
this.id = entity.getId();
this.name = entity.getName();
this.description = entity.getDescription();
this.entityAllowedToSendCard = entity.getEntityAllowedToSendCard();
this.parents = entity.getParents().stream().collect(Collectors.toSet());
this.roles = entity.getRoles().stream().collect(Collectors.toSet());
}
Expand Down
2 changes: 0 additions & 2 deletions services/users/src/main/modeling/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ definitions:
type: array
items:
type: string
entityAllowedToSendCard:
type: boolean
parents:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2022-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -47,16 +47,16 @@ void clear() {
eventBusSpy = new EventBusSpy();
NotificationService notificationService = new NotificationService(userRepositoryStub, eventBusSpy);
entitiesService = new EntitiesService(entityRepositoryStub, userRepositoryStub, notificationService);
EntityData entity1 = new EntityData("entity1", "Entity 1", "Entity 1 Desc", null, null, null, null);
EntityData entity1 = new EntityData("entity1", "Entity 1", "Entity 1 Desc", null, null, null);
entityRepositoryStub.save(entity1);
EntityData entity2 = new EntityData("entity2", "Entity 2", null, null, null, null, null);
EntityData entity2 = new EntityData("entity2", "Entity 2", null, null, null, null);
entityRepositoryStub.save(entity2);

Set<String> parent = new HashSet<>(Arrays.asList("entity1", "entity2"));
EntityData child1 = new EntityData("child1", "Entity child", null, null, null, parent, null);
EntityData child1 = new EntityData("child1", "Entity child", null, null, parent, null);
entityRepositoryStub.save(child1);
Set<String> parent2 = new HashSet<>(Arrays.asList("entity1"));
EntityData child2 = new EntityData("child2", "Entity child 2", null, null, null, parent2, null);
EntityData child2 = new EntityData("child2", "Entity child 2", null, null, parent2, null);
entityRepositoryStub.save(child2);

Set<String> entitiesForUser1 = new HashSet<>(Arrays.asList("entity1", "entity2"));
Expand Down Expand Up @@ -99,7 +99,7 @@ void GIVEN_Existing_Entity_In_Repository_WHEN_Fetch_Entity_THEN_Success_And_Retu
class Create {
@Test
void GIVEN_An_Invalid_EntityId__WHEN_Creating_Entity_THEN_Return_Bad_Request() {
EntityData entity = new EntityData("invalid id", "invalid id", null, null, null, null, null);
EntityData entity = new EntityData("invalid id", "invalid id", null, null, null, null);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isFalse();
assertThat(result.getErrorType()).isEqualTo(OperationResult.ErrorType.BAD_REQUEST);
Expand All @@ -109,7 +109,7 @@ void GIVEN_An_Invalid_EntityId__WHEN_Creating_Entity_THEN_Return_Bad_Request() {
void GIVEN_A_Valid_Entity_WHEN_Create_Entity_THEN_Return_Created_Entity() {
Set<RolesEnum> roles = new HashSet<>(Arrays.asList(RolesEnum.CARD_RECEIVER, RolesEnum.CARD_SENDER));

EntityData entity = new EntityData("newEntity", "name", "myDescription", null, true, null, roles);
EntityData entity = new EntityData("newEntity", "name", "myDescription", null, null, roles);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isTrue();
assertThat(result.getResult().isUpdate()).isFalse();
Expand All @@ -122,7 +122,9 @@ void GIVEN_A_Valid_Entity_WHEN_Create_Entity_THEN_Return_Created_Entity() {

@Test
void GIVEN_A_Valid_Entity_WHEN_Create_An_Already_Existing_Entity_THEN_Entity_Is_Updated() {
EntityData entity = new EntityData("entity1", "newEntityName", null, null, true, null, null);
Set<RolesEnum> roles = new HashSet<>(Arrays.asList(RolesEnum.CARD_RECEIVER, RolesEnum.CARD_SENDER));

EntityData entity = new EntityData("entity1", "newEntityName", null, null, null, roles);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isTrue();
assertThat(result.getResult().isUpdate()).isTrue();
Expand All @@ -133,7 +135,9 @@ void GIVEN_A_Valid_Entity_WHEN_Create_An_Already_Existing_Entity_THEN_Entity_Is_

@Test
void GIVEN_A_Valid_Entity_WHEN_Update_Description_With_Same_Name_THEN_Entity_Is_Updated() {
EntityData entity = new EntityData("entity1", "Entity 1", "new description", null, true, null, null);
Set<RolesEnum> roles = new HashSet<>(Arrays.asList(RolesEnum.CARD_RECEIVER, RolesEnum.CARD_SENDER));

EntityData entity = new EntityData("entity1", "Entity 1", "new description", null, null, roles);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isTrue();
assertThat(result.getResult().isUpdate()).isTrue();
Expand All @@ -148,7 +152,7 @@ void GIVEN_A_Valid_Entity_WHEN_Update_Description_With_Same_Name_THEN_Entity_Is_
void GIVEN_A_Entity_With_Entity_Cycle_WHEN_Create_Entity_THEN_Return_BAD_REQUEST() {

Set<String> childAsParent = new HashSet<>(Arrays.asList("child1"));
EntityData group = new EntityData("entity1", "groupName", null, null, null, childAsParent, null);
EntityData group = new EntityData("entity1", "groupName", null, null, childAsParent, null);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(group);
assertThat(result.isSuccess()).isFalse();
assertThat(result.getErrorType()).isEqualTo(OperationResult.ErrorType.BAD_REQUEST);
Expand All @@ -157,7 +161,9 @@ void GIVEN_A_Entity_With_Entity_Cycle_WHEN_Create_Entity_THEN_Return_BAD_REQUEST

@Test
void GIVEN_A_Valid_Entity_with_An_Already_Existing_Name_WHEN_Try_To_Create_Entity_THEN_Return_Bad_Request() {
EntityData entity = new EntityData("newEntity", "Entity 1", "myDescription", null, true, null, null);
Set<RolesEnum> roles = new HashSet<>(Arrays.asList(RolesEnum.CARD_RECEIVER, RolesEnum.CARD_SENDER));

EntityData entity = new EntityData("newEntity", "Entity 1", "myDescription", null, null, roles);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isFalse();
assertThat(result.getErrorType()).isEqualTo(OperationResult.ErrorType.BAD_REQUEST);
Expand All @@ -167,7 +173,9 @@ void GIVEN_A_Valid_Entity_with_An_Already_Existing_Name_WHEN_Try_To_Create_Entit

@Test
void GIVEN_A_Valid_Existing_Entity_WHEN_Try_To_Update_Entity_with_An_Already_Existing_Name_THEN_Return_Bad_Request() {
EntityData entity = new EntityData("entity2", "Entity 1", "myDescription", null, true, null, null);
Set<RolesEnum> roles = new HashSet<>(Arrays.asList(RolesEnum.CARD_RECEIVER, RolesEnum.CARD_SENDER));

EntityData entity = new EntityData("entity2", "Entity 1", "myDescription", null, null, roles);
OperationResult<EntityCreationReport<Entity>> result = entitiesService.createEntity(entity);
assertThat(result.isSuccess()).isFalse();
assertThat(result.getErrorType()).isEqualTo(OperationResult.ErrorType.BAD_REQUEST);
Expand Down
1 change: 0 additions & 1 deletion src/docs/asciidoc/reference_doc/ui_api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Entity object contains the following fields :
- 'id' : id of the entity
- 'name' : name of the entity
- 'description' : description of the entity
- 'entityAllowedToSendCard' : boolean indicating whether the entity is allowed to send cards or not
- 'parents' : list of parent entities
- 'labels' : list of labels associated to the entity

Expand Down
4 changes: 1 addition & 3 deletions src/docs/asciidoc/resources/migration_guide_to_4.2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@ Now entities shouldn't be grouped in the configuration file anymore. Instead ent
----


With this parent entity 1 and parent entity 2 need to be declared and the name of the parent entities will be the name of the groups.

With this parent entity 1 and parent entity 2 need to be declared and the name of the parent entities will be the name of the group.
With this parent entity 1 and parent entity 2 need to be declared and the name of the parent entities will be the name of the groups.
3 changes: 0 additions & 3 deletions src/test/api/karate/users/entities/createEntities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Feature: CreateEntities
"name" : "entityKarate1 name",
"description" : "I Love Karate",
"labels" : ["Label2", "Label3"],
"entityAllowedToSendCard" : false,
"roles" : ["ACTIVITY_AREA_GROUP"]
}
"""
Expand Down Expand Up @@ -115,7 +114,6 @@ Feature: CreateEntities
And match response.description == entity.description
And match response.name == entity.name
And match response.id == entity.id
And match response.entityAllowedToSendCard == true
And assert response.labels.length == 1
And match response.labels[0] == 'Label1'
And assert response.roles.length == 1
Expand All @@ -132,7 +130,6 @@ Feature: CreateEntities
And match response.description == entityUpdated.description
And match response.name == entityUpdated.name
And match response.id == entity.id
And match response.entityAllowedToSendCard == false
And assert response.labels.length == 2
And match response.labels contains ['Label2', 'Label3']
And assert response.roles.length == 1
Expand Down
16 changes: 11 additions & 5 deletions src/test/cypress/cypress/integration/Admin.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2022-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -165,10 +165,12 @@ describe('AdmininstrationPages', () => {

cy.get('#opfab-description').type('entity description');

cy.get('#opfab-entity-allowed-to-send-card').check({force: true});

cy.get('tag-input').find('[aria-label="Add label"]').eq(0).type('Label1');

cy.get('#opfab-roles').click();
cy.get('#opfab-roles').find('.vscomp-option-text').eq(2).click({force: true});
cy.get('#opfab-roles').click();

cy.get('#opfab-parents').click();
cy.get('#opfab-parents').find('.vscomp-option-text').eq(1).click({force: true});
cy.get('#opfab-parents').click();
Expand Down Expand Up @@ -203,8 +205,12 @@ describe('AdmininstrationPages', () => {

cy.get('#opfab-description').type(' updated');

cy.get('#opfab-entity-allowed-to-send-card').should('be.checked');
cy.get('#opfab-entity-allowed-to-send-card').uncheck({force: true});
cy.get('#opfab-roles').click();
// Deselect old parents
cy.get('#opfab-roles').find('.vscomp-option-text').eq(2).click({force: true});
// Select new parent
cy.get('#opfab-roles').find('.vscomp-option-text').eq(1).click({force: true});
cy.get('#opfab-roles').click();


cy.get('tag-input').find('[aria-label="Label1"]').should('exist');
Expand Down
16 changes: 8 additions & 8 deletions src/test/cypress/cypress/integration/CardDetail.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2021-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2021-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -51,25 +51,25 @@ describe('Card detail', function () {
cy.get('#opfab-currentCard-getEntitiesUsableForUserResponse').contains(/^ENTITY1_FR$/);
cy.get('#opfab-currentCard-getDisplayContext').contains(/^realtime$/);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[0]:id=ENTITY1_FR,name=Control Center FR North,description=Control Center FR North,entityAllowedToSendCard=true,parents=ENTITY_FR,labels=FR1 label'
'entity[0]:id=ENTITY1_FR,name=Control Center FR North,description=Control Center FR North,roles=CARD_SENDER,CARD_RECEIVER,parents=ENTITY_FR,labels=FR1 label'
);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[1]:id=ENTITY2_FR,name=Control Center FR South,description=Control Center FR South,entityAllowedToSendCard=true,parents=ENTITY_FR,labels=undefined'
'entity[1]:id=ENTITY2_FR,name=Control Center FR South,description=Control Center FR South,roles=CARD_SENDER,CARD_RECEIVER,parents=ENTITY_FR,labels=undefined'
);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[2]:id=ENTITY3_FR,name=Control Center FR East,description=Control Center FR East,entityAllowedToSendCard=true,parents=ENTITY_FR,labels=undefined'
'entity[2]:id=ENTITY3_FR,name=Control Center FR East,description=Control Center FR East,roles=CARD_SENDER,CARD_RECEIVER,parents=ENTITY_FR,labels=undefined'
);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[3]:id=ENTITY4_FR,name=Control Center FR West,description=Control Center FR West,entityAllowedToSendCard=true,parents=ENTITY_FR,labels=undefined'
'entity[3]:id=ENTITY4_FR,name=Control Center FR West,description=Control Center FR West,roles=CARD_SENDER,CARD_RECEIVER,parents=ENTITY_FR,labels=undefined'
);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[4]:id=ENTITY_FR,name=French Control Centers,description=French Control Centers,entityAllowedToSendCard=false,parents=undefined,labels=undefined'
'entity[4]:id=ENTITY_FR,name=French Control Centers,description=French Control Centers,roles=ACTIVITY_AREA_GROUP,CARD_RECEIVER,parents=undefined,labels=undefined'
);
cy.get('#opfab-users-entities-getAllEntities').contains(
'entity[6]:id=IT_SUPERVISOR_ENTITY,name=IT SUPERVISION CENTER,description=IT SUPERVISION CENTER,entityAllowedToSendCard=true,parents=EUROPEAN_SUPERVISION_CENTERS,labels=undefined'
'entity[6]:id=IT_SUPERVISOR_ENTITY,name=IT SUPERVISION CENTER,description=IT SUPERVISION CENTER,roles=CARD_SENDER,CARD_RECEIVER,parents=EUROPEAN_SUPERVISION_CENTERS,labels=undefined'
);
cy.get('#opfab-users-entities-getEntity-ENTITY1_FR').contains(
/^ENTITY1_FR,Control Center FR North,Control Center FR North,true,ENTITY_FR,FR1 label$/
/^ENTITY1_FR,Control Center FR North,Control Center FR North,CARD_SENDER,CARD_RECEIVER,ENTITY_FR,FR1 label$/
);
cy.get('#screenSize').contains('md');
cy.get('#opfab-currentCard-onTemplateRenderingComplete').contains('ok');
Expand Down

0 comments on commit 592b305

Please sign in to comment.