2727@ ExtendWith (MockitoExtension .class )
2828class HmiServiceTest {
2929
30+ private static final String DQC_REPORT_TYPE = "DQC" ;
31+ private static final String CYC_REPORT_TYPE = "CYC" ;
3032 @ InjectMocks
3133 HmiService hmiService ;
3234
@@ -42,7 +44,7 @@ void setUp() {
4244 void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_controlblock () {
4345 // Given
4446 SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
45- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
47+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
4648 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
4749 // When
4850 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -69,7 +71,7 @@ void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_contro
6971 void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_controlblock () {
7072 // Given
7173 SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
72- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX );
74+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX , CYC_REPORT_TYPE );
7375 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
7476 // When
7577 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -93,11 +95,39 @@ void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_contro
9395 assertThat (reportControl .getRptEnabled ().isSetClientLN ()).isFalse ();
9496 }
9597
98+ @ Test
99+ void createAllIhmReportControlBlocks_with_fc_MX_and_DQC_REPORT_TYPE_should_create_dataset_and_controlblock_with_suffix_DQPO () {
100+ // Given
101+ SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
102+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX , DQC_REPORT_TYPE );
103+ po .getFCDAs ().getFCDA ().add (tfcdaFilter );
104+ // When
105+ hmiService .createAllHmiReportControlBlocks (scd , po );
106+ // Then
107+ // Check DataSet is created
108+ DataSetAdapter dataSet = findDataSet (scd , "IedName1" , "LdInst11" , "DS_LDINST11_DQPO" );
109+ assertThat (dataSet .getCurrentElem ().getFCDA ()).hasSize (1 ).first ()
110+ .usingRecursiveComparison ().isEqualTo (toFCDA (tfcdaFilter ));
111+ // Check ControlBlock is created
112+ LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
113+ assertThat (ln0 .getTControlsByType (TReportControl .class )).hasSize (1 );
114+
115+ TReportControl reportControl = findControlBlock (scd , "IedName1" , "LdInst11" , "CB_LDINST11_DQPO" , TReportControl .class );
116+ assertThat (reportControl ).extracting (TReportControl ::getRptID , TControl ::getDatSet , TReportControl ::getConfRev , TReportControl ::isBuffered , TReportControl ::getBufTime , TReportControl ::isIndexed ,
117+ TControlWithTriggerOpt ::getIntgPd )
118+ .containsExactly ("IedName1LdInst11/LLN0.CB_LDINST11_DQPO" , "DS_LDINST11_DQPO" , 1L , true , 0L , true , 60000L );
119+ assertThat (reportControl .getTrgOps ())
120+ .extracting (TTrgOps ::isDchg , TTrgOps ::isQchg , TTrgOps ::isDupd , TTrgOps ::isPeriod , TTrgOps ::isGi )
121+ .containsExactly (true , true , false , true , true );
122+ assertThat (reportControl .getRptEnabled ().getMax ()).isEqualTo (1 );
123+ assertThat (reportControl .getRptEnabled ().isSetClientLN ()).isFalse ();
124+ }
125+
96126 @ Test
97127 void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_controlblock () {
98128 // Given
99129 SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
100- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "LLN0" , null , null , "DoName0" , Tfc .ST );
130+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "LLN0" , null , null , "DoName0" , Tfc .ST , DQC_REPORT_TYPE );
101131 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
102132 // When
103133 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -126,7 +156,7 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_sh
126156 SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
127157 LNAdapter ln = findLn (scd , "IedName1" , "LdInst11" , "ANCR" , "1" , null );
128158 ln .getCurrentElem ().unsetDOI ();
129- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
159+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
130160 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
131161 // When
132162 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -151,7 +181,7 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_OFF_should
151181 LNAdapter ln = findLn (scd , "IedName1" , "LdInst11" , "ANCR" , "1" , null );
152182 ln .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).setVal ("off" );
153183 assertThat (ln .getDaiModStValValue ()).hasValue ("off" );
154- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
184+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
155185 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
156186 // When
157187 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -167,7 +197,7 @@ void createAllIhmReportControlBlocks_when_lDevice_OFF_should_not_create_dataset(
167197 LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
168198 ln0 .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).setVal ("off" );
169199 assertThat (findLDevice (scd , "IedName1" , "LdInst11" ).getLDeviceStatus ()).hasValue (ActiveStatus .OFF .getValue ());
170- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
200+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
171201 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
172202 // When
173203 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -183,7 +213,7 @@ void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_creat
183213 LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
184214 ln0 .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).getCurrentElem ().unsetVal ();
185215 assertThat (findLDevice (scd , "IedName1" , "LdInst11" ).getLDeviceStatus ()).isEmpty ();
186- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
216+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
187217 po .getFCDAs ().getFCDA ().add (tfcdaFilter );
188218 // When
189219 hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -192,14 +222,15 @@ void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_creat
192222 assertThat (streamAllControlBlocks (scd , TReportControl .class )).isEmpty ();
193223 }
194224
195- private static TFCDAFilter createFCDAFilter (String ldInst , String lnClass , String lnInst , String prefix , String doName , Tfc tfc ) {
225+ private static TFCDAFilter createFCDAFilter (String ldInst , String lnClass , String lnInst , String prefix , String doName , Tfc tfc , String reportType ) {
196226 TFCDAFilter tfcdaFilter = new TFCDAFilter ();
197- tfcdaFilter .setLdInst ("LdInst11" );
227+ tfcdaFilter .setLdInst (ldInst );
198228 tfcdaFilter .setLnClass (lnClass );
199- tfcdaFilter .setPrefix (null );
229+ tfcdaFilter .setPrefix (prefix );
200230 tfcdaFilter .setDoName (doName );
201231 tfcdaFilter .setLnInst (lnInst );
202232 tfcdaFilter .setFc (tfc );
233+ tfcdaFilter .setReportType (reportType );
203234 return tfcdaFilter ;
204235 }
205236
0 commit comments