Skip to content

Commit

Permalink
feat(211): Add null test case for LDeviceAdapter hasDataSetCreationCa…
Browse files Browse the repository at this point in the history
…pability and hasControlBlockCreationCapability

Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
  • Loading branch information
massifben committed Dec 29, 2022
1 parent 9649204 commit c603018
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.lfenergy.compas.sct.commons.scl.ied;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -309,6 +310,20 @@ void hasDataSetCreationCapability_should_return_false_when_no_existing_services_
assertThat(hasCapability).isFalse();
}

@Test
void hasDataSetCreationCapability_should_throw_exception_when_parameter_is_null() throws Exception {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName("IED_NAME");
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst("LD_INS1");
iedAdapter.getCurrentElem().getAccessPoint().get(0).setServices(new TServices());

// When & Then
Assertions.assertThatThrownBy(() -> lDeviceAdapter.hasDataSetCreationCapability(null))
.isInstanceOf(NullPointerException.class);
}


@ParameterizedTest(name = "{0}")
@MethodSource("provideHasControlBlockCreationCapabilityTrue")
Expand Down Expand Up @@ -400,7 +415,6 @@ private static Stream<Arguments> provideHasControlBlockCreationCapabilityFalse()
);
}


@ParameterizedTest
@EnumSource(ServiceSettingsType.class)
void hasControlBlockCreationCapability_should_return_false_when_no_existing_services_attribute(ServiceSettingsType serviceSettingsType) throws Exception {
Expand All @@ -417,5 +431,19 @@ void hasControlBlockCreationCapability_should_return_false_when_no_existing_serv
assertThat(hasCapability).isFalse();
}

@Test
void hasControlBlockCreationCapability_should_throw_exception_when_parameter_is_null() throws Exception {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName("IED_NAME");
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst("LD_INS1");
iedAdapter.getCurrentElem().getAccessPoint().get(0).setServices(new TServices());

// When & Then
Assertions.assertThatThrownBy(() -> lDeviceAdapter.hasControlBlockCreationCapability(null))
.isInstanceOf(NullPointerException.class);
}

}

0 comments on commit c603018

Please sign in to comment.