-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feat/66 automated std import ied communication #101
Conversation
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>
62f6eb1
to
ca1d917
Compare
219ab20
to
ca1d917
Compare
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>
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
Outdated
Show resolved
Hide resolved
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
Outdated
Show resolved
Hide resolved
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java
Outdated
Show resolved
Hide resolved
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java
Show resolved
Hide resolved
</History> | ||
</Header> | ||
<Communication> | ||
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK"> |
There was a problem hiding this comment.
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
<SubNetwork type="8-MMS" name="RSPACE_PROCESS_NETWORK"> | |
<SubNetwork type="8-MMS" name="PROCESS_NETWORK"> |
<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> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<SubNetwork type="IP" name="RSPACE_ADMIN_NETWORK"> | |
<SubNetwork type="IP" name="ADMIN_NETWORK"> |
<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> |
There was a problem hiding this comment.
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>
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>
Kudos, SonarCloud Quality Gate passed! |
|
||
@Slf4j | ||
public class SclAutomationService { | ||
|
||
private static final Map<Pair<String, String>, List<String>> comMap = Map.of( |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
Outdated
Show resolved
Hide resolved
|
||
public static SclRootAdapter importSTDElementsInSCD(@NonNull SclRootAdapter scdRootAdapter, Set<SCL> stds, | ||
Map<Pair<String, String>, List<String>> comMap) throws ScdException { | ||
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Import multiple STD files (IED, DataTypeTemplates and Communication) into SCD