|
8 | 8 | import org.junit.jupiter.api.BeforeEach; |
9 | 9 | import org.junit.jupiter.api.Tag; |
10 | 10 | import org.junit.jupiter.api.Test; |
11 | | -import org.junit.jupiter.params.ParameterizedTest; |
12 | | -import org.junit.jupiter.params.provider.CsvSource; |
13 | 11 | import org.lfenergy.compas.scl2007b4.model.*; |
14 | 12 | import org.lfenergy.compas.sct.commons.api.DataTypeTemplateReader; |
15 | 13 | import org.lfenergy.compas.sct.commons.dto.*; |
16 | 14 | import org.lfenergy.compas.sct.commons.exception.ScdException; |
17 | 15 | import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; |
18 | | -import org.lfenergy.compas.sct.commons.scl.ied.DOIAdapter; |
19 | | -import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; |
20 | 16 | import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; |
21 | | -import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; |
22 | 17 | import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; |
23 | 18 | import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; |
24 | 19 |
|
25 | 20 | import java.util.List; |
26 | | -import java.util.Optional; |
27 | 21 | import java.util.UUID; |
28 | 22 |
|
29 | 23 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -345,124 +339,6 @@ void importSTDElementsInSCD_whenNoSTDMatch_shouldThrowException() { |
345 | 339 | .hasMessage("There is no STD file found corresponding to headerId = f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa, headerVersion = 01.00.00, headerRevision = 01.00.00 and ICDSystemVersionUUID = IED4d4fe1a8cda64cf88a5ee4176a1a0eef"); |
346 | 340 | } |
347 | 341 |
|
348 | | - @ParameterizedTest(name = "{0}") |
349 | | - @CsvSource({ |
350 | | - "Test update setSrcRef Value,LD_WITH_1_InRef,InRef2,setSrcRef,IED_NAME1LD_WITH_1_InRef/PRANCR1.Do11.sdo11", |
351 | | - "Test update setSrcCB Value,LD_WITH_1_InRef,InRef2,setSrcCB,OLD_VAL", |
352 | | - "Test update setSrcRef Value,LD_WITH_3_InRef,InRef3,setSrcRef,IED_NAME1LD_WITH_3_InRef/PRANCR1.Do11.sdo11", |
353 | | - "Test update setSrcCB Value,LD_WITH_3_InRef,InRef3,setSrcCB,IED_NAME1LD_WITH_3_InRef/prefixANCR1.GSE1" |
354 | | - }) |
355 | | - void updateDoInRef_shouldReturnUpdatedFile(String testName, String ldInst, String doName, String daName, String expected) { |
356 | | - // Given |
357 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_issue_231_test_ok.xml"); |
358 | | - // When |
359 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
360 | | - // Then |
361 | | - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue(); |
362 | | - assertSclValidateXsd(givenScl); |
363 | | - assertThat(getValFromDaiName(givenScl, "IED_NAME1", ldInst, doName, daName) |
364 | | - .map(TVal::getValue)) |
365 | | - .hasValue(expected); |
366 | | - assertSclValidateXsd(givenScl); |
367 | | - } |
368 | | - |
369 | | - @ParameterizedTest(name = "{0}") |
370 | | - @CsvSource({ |
371 | | - "Test with only 1 ExtRef should not update DO when IedName not present,LD_WITH_1_InRef_ExtRef_Without_IedName,InRef4,setSrcRef", |
372 | | - "Test with only 1 ExtRef should not update DO when LdInst not present,LD_WITH_1_InRef_ExtRef_Without_LdInst,InRef5,setSrcRef", |
373 | | - "Test with only 1 ExtRef should not update DO when lnClass not present,LD_WITH_1_InRef_ExtRef_Without_LnClass,InRef6,setSrcRef" |
374 | | - }) |
375 | | - void updateDoInRef_should_not_update_DAI(String testName, String ldInst, String doName, String daName) { |
376 | | - // Given |
377 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_issue_231_test_ok.xml"); |
378 | | - // When |
379 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
380 | | - // Then |
381 | | - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue(); |
382 | | - assertThat(getValFromDaiName(givenScl, "IED_NAME1", ldInst, doName, daName)).isNotPresent(); |
383 | | - } |
384 | | - |
385 | | - @Test |
386 | | - void updateDoInRef_when_No_ExtRef_for_InRef_should_not_return_error() { |
387 | | - // Given |
388 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_no_Extref.xml"); |
389 | | - // When |
390 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
391 | | - // Then |
392 | | - assertThat(sclReportItems).isEmpty(); |
393 | | - } |
394 | | - |
395 | | - @Test |
396 | | - void updateDoInRef_when_ExtRef_bind_and_desc_suffix_not_match_should_not_return_error() { |
397 | | - // Given |
398 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_extref_bind_desc_suffix_not_match.xml"); |
399 | | - // When |
400 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
401 | | - // Then |
402 | | - assertThat(sclReportItems).isEmpty(); |
403 | | - } |
404 | | - |
405 | | - @Test |
406 | | - void updateDoInRef_when_ExtRef_bind_should_succeed() { |
407 | | - // Given |
408 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_extref_bind.xml"); |
409 | | - // When |
410 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
411 | | - // Then |
412 | | - assertThat(sclReportItems).isEmpty(); |
413 | | - assertThat(givenScl.getIED()) |
414 | | - .filteredOn(tied -> tied.getName().equals("IED_NAME1")) |
415 | | - .flatExtracting(TIED::getAccessPoint) |
416 | | - .extracting(TAccessPoint::getServer) |
417 | | - .flatExtracting(TServer::getLDevice) |
418 | | - .filteredOn(tlDevice -> tlDevice.getInst().equals("LD1")) |
419 | | - .map(TLDevice::getLN0) |
420 | | - .flatExtracting(TAnyLN::getDOI) |
421 | | - .filteredOn(tdoi -> tdoi.getName().equals("InRef1")) |
422 | | - .flatExtracting(TDOI::getSDIOrDAI) |
423 | | - .filteredOn(tUnNaming -> tUnNaming.getClass().equals(TDAI.class) && ((TDAI)tUnNaming).getName().equals("setSrcRef")) |
424 | | - .map(tUnNaming -> ((TDAI)tUnNaming).getVal().getFirst().getValue()) |
425 | | - .containsExactly("IED_NAME1LD2/PRANCR1.Do11.sdo11"); |
426 | | - } |
427 | | - |
428 | | - @Test |
429 | | - void updateDoInRef_when_ExtRef_bind_should_not_return_error() { |
430 | | - // Given |
431 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_extref_not_bind.xml"); |
432 | | - // When |
433 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
434 | | - // Then |
435 | | - assertThat(sclReportItems).isEmpty(); |
436 | | - } |
437 | | - |
438 | | - @Test |
439 | | - void updateDoInRef_when_Inref_purpose_not_set_should_return_report_with_warning() { |
440 | | - // Given |
441 | | - SCL givenScl = SclTestMarshaller.getSCLFromResource("scd-test-update-inref/scd_update_inref_when_inref_purpose_not_set.xml"); |
442 | | - // When |
443 | | - List<SclReportItem> sclReportItems = sclService.updateDoInRef(givenScl); |
444 | | - // Then |
445 | | - assertThat(sclReportItems.stream().filter(sclReportItem -> !sclReportItem.isError()).map(SclReportItem::message)) |
446 | | - .hasSize(1) |
447 | | - .containsExactly("The DOI /SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_Without_Val_in_DAI_purpose\"]/LN0 can't be bound with an ExtRef"); |
448 | | - } |
449 | | - |
450 | | - private Optional<TVal> getValFromDaiName(SCL scl, String iedName, String ldInst, String doiName, String daiName) { |
451 | | - SclRootAdapter sclRootAdapter = new SclRootAdapter(scl); |
452 | | - IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(iedName); |
453 | | - Optional<LDeviceAdapter> lDeviceAdapter = iedAdapter.findLDeviceAdapterByLdInst(ldInst); |
454 | | - LN0Adapter ln0Adapter = lDeviceAdapter.orElseThrow().getLN0Adapter(); |
455 | | - Optional<DOIAdapter> doiAdapter = ln0Adapter.getDOIAdapters().stream() |
456 | | - .filter(doiAdapter1 -> doiAdapter1.getCurrentElem().getName().equals(doiName)) |
457 | | - .findFirst(); |
458 | | - return doiAdapter.flatMap(adapter -> adapter.getCurrentElem().getSDIOrDAI().stream() |
459 | | - .filter(tUnNaming -> tUnNaming.getClass().equals(TDAI.class)) |
460 | | - .map(TDAI.class::cast) |
461 | | - .filter(tdai -> tdai.getName().equals(daiName) && !tdai.getVal().isEmpty()) |
462 | | - .map(tdai -> tdai.getVal().getFirst()) |
463 | | - .findFirst()); |
464 | | - } |
465 | | - |
466 | 342 | @Test |
467 | 343 | void manageMonitoringLns_should_update_and_create_lsvs_and_goose() { |
468 | 344 | // Given |
|
0 commit comments