diff --git a/src/main/java/org/gridsuite/modification/server/modifications/SubstationCreation.java b/src/main/java/org/gridsuite/modification/server/modifications/SubstationCreation.java index 406c136be..31fd2bb85 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/SubstationCreation.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/SubstationCreation.java @@ -8,6 +8,7 @@ import org.gridsuite.modification.server.dto.SubstationCreationInfos; import java.util.Map; +import java.util.Optional; public class SubstationCreation extends AbstractModification { @@ -47,12 +48,15 @@ public void apply(Network network, Reporter subReporter) { .reportElementaryCreation(subReporter, modificationInfos.getSubstationCountry(), "Country"); } // properties - modificationInfos.getProperties().forEach((key, value) -> subReporter.report(Report.builder() - .withKey("propertyAdded") - .withDefaultMessage(" Property ${name} added with value ${value}") - .withValue("name", key) - .withValue("value", value) - .withSeverity(TypedValue.INFO_SEVERITY) - .build())); + Optional.ofNullable(modificationInfos.getProperties()) + .filter(propertie -> !properties.isEmpty()) + .ifPresent(propertie -> properties.forEach((key, value) -> subReporter.report(Report.builder() + .withKey("propertyAdded") + .withDefaultMessage(" Property ${name} added with value ${value}") + .withValue("name", key) + .withValue("value", value) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()))); + } }