Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/66 automated std import ied communication #101

Merged
merged 14 commits into from
May 10, 2022

Conversation

AliouDIAITE
Copy link
Member

Import multiple STD files (IED, DataTypeTemplates and Communication) into SCD

@AliouDIAITE AliouDIAITE added this to the 0.0.4 milestone Apr 28, 2022
@AliouDIAITE AliouDIAITE self-assigned this Apr 28, 2022
AliouDIAITE and others added 8 commits April 28, 2022 17:03
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
#91)

* Update SCL communication import method to allow the import of the attributes Address et PhysConn if present.

Signed-off-by: SAINTIER FRANCOIS <francois.saintier@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
@AliouDIAITE AliouDIAITE force-pushed the feat/66-Automated-STD-Import-IED-Communication branch from 62f6eb1 to ca1d917 Compare April 28, 2022 15:03
@AliouDIAITE AliouDIAITE force-pushed the feat/66-Automated-STD-Import-IED-Communication branch from 219ab20 to ca1d917 Compare April 28, 2022 15:20
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
</History>
</Header>
<Communication>
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the others, generify file

Suggested change
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK">
<SubNetwork type="8-MMS" name="PROCESS_NETWORK">

Comment on lines +48 to +51
<Private type="RTE-ProjectStage">Phase 1_Pilotes</Private>
<Private type="RTE-FunctionUUID">9d13ab59-1ec8-4c46-91c8-0326e6a5408e</Private>
<Private type="RTE-LDMaxInst">1</Private>
<Private type="RTE-FunctionIndice">1.0</Private>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generify file

</History>
</Header>
<Communication>
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK">
<SubNetwork type="8-MMS" name="PROCESS_NETWORK">

</Address>
</ConnectedAP>
</SubNetwork>
<SubNetwork type="IP" name="RSPACE_ADMIN_NETWORK">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<SubNetwork type="IP" name="RSPACE_ADMIN_NETWORK">
<SubNetwork type="IP" name="ADMIN_NETWORK">

Comment on lines +48 to +51
<Private type="RTE-ProjectStage">Phase 1_Pilotes</Private>
<Private type="RTE-FunctionUUID">9d13ab59-1ec8-4c46-91c8-0326e6a5408e</Private>
<Private type="RTE-LDMaxInst">1</Private>
<Private type="RTE-FunctionIndice">1.0</Private>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generify file

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
SaintierFr
SaintierFr previously approved these changes May 10, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.8% 90.8% Coverage
0.0% 0.0% Duplication


@Slf4j
public class SclAutomationService {

private static final Map<Pair<String, String>, List<String>> comMap = Map.of(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps a more precise name like communicationMap ?

@@ -29,11 +31,15 @@ void init(){

@Test
void createSCD() throws Exception {
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to create blocs \Given \When \Then for better readability in all tests. Here the code is too dense

SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(1 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this assertion is related to HItem creation ?

assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals("what", expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().get(0).getWhat());
}

@Test
@Test
void createSCD_SSD_Without_Substation() throws Exception {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important to show the test intention with its name. Here it is not evident to know if we check the creation or an error (except the throws exception). I suggest something like should_not_create_SCD_SSD_without_substation()


public static SclRootAdapter importSTDElementsInSCD(@NonNull SclRootAdapter scdRootAdapter, Set<SCL> stds,
Map<Pair<String, String>, List<String>> comMap) throws ScdException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big method, could it be devided ?
Instead of comments try to create private methods with good naming.

.collect(Collectors.toMap(tPrivate -> getValueFromPrivate(tPrivate, CommonConstants.IED_NAME), tPrivate -> tPrivate));
}

private static Map<String, Pair<TPrivate, List<SCL>>> createMapICDSystemVersionUuidAndSTDFile(Set<SCL> stds) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming suggestion : createSTDFileByICDSystemVersionUuidMap

import org.lfenergy.compas.scl2007b4.model.*;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class DTO {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too generic class name. What is the purpose, responsability of this class ?

CommonConstants.HW_REV, CommonConstants.SW_REV, CommonConstants.HEADER_ID, CommonConstants.HEADER_VERSION,
CommonConstants.HEADER_REVISION);

Element iedElement = (Element) iedPrivate.getContent().get(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get(1) how do you know it is the second element that you seek ? And there is potentially a risk of NullPointerException

@@ -42,4 +48,27 @@ void testFrom(){

}

@Test
void testCreateDefaultSubnetwork() {
CommunicationAdapter comAdapter = Mockito.mock(CommunicationAdapter.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder for tests devided in \Given \When \Then blocs

@AliouDIAITE AliouDIAITE merged commit 36643fa into develop May 10, 2022
@AliouDIAITE AliouDIAITE deleted the feat/66-Automated-STD-Import-IED-Communication branch May 10, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants