From 59682841865c29b09a509bfa62da4cd714a0547e Mon Sep 17 00:00:00 2001 From: Thang PHAM Date: Fri, 13 Sep 2024 00:03:28 +0200 Subject: [PATCH] Unit test fail --- .../byfilter/ModificationByAssignment.java | 3 +++ .../GeneratorModificationByAssignmentTest.java | 17 +---------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/server/modifications/byfilter/ModificationByAssignment.java b/src/main/java/org/gridsuite/modification/server/modifications/byfilter/ModificationByAssignment.java index 7b9a94b13..6fccbf7e5 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/byfilter/ModificationByAssignment.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/byfilter/ModificationByAssignment.java @@ -87,6 +87,9 @@ protected String getOldValue(Identifiable equipment, AbstractAssignmentInfos @Override protected String getNewValue(Identifiable equipment, AbstractAssignmentInfos abstractAssignmentInfos) { AssignmentInfos simpleModificationInfos = (AssignmentInfos) abstractAssignmentInfos; + if (simpleModificationInfos.getValue() == null) { + throw new NetworkModificationException(MODIFICATION_BY_ASSIGNMENT_ERROR, "There is no value in assignment"); + } return simpleModificationInfos.getValue().toString(); } diff --git a/src/test/java/org/gridsuite/modification/server/modifications/byfilter/assignment/GeneratorModificationByAssignmentTest.java b/src/test/java/org/gridsuite/modification/server/modifications/byfilter/assignment/GeneratorModificationByAssignmentTest.java index b92d11f05..5c166ccc2 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/byfilter/assignment/GeneratorModificationByAssignmentTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/byfilter/assignment/GeneratorModificationByAssignmentTest.java @@ -14,11 +14,10 @@ import org.gridsuite.filter.identifierlistfilter.IdentifierListFilter; import org.gridsuite.filter.identifierlistfilter.IdentifierListFilterEquipmentAttributes; import org.gridsuite.filter.utils.EquipmentType; -import org.gridsuite.modification.server.dto.FilterInfos; -import org.gridsuite.modification.server.dto.byfilter.equipmentfield.GeneratorField; import org.gridsuite.modification.server.dto.byfilter.assignment.AssignmentInfos; import org.gridsuite.modification.server.dto.byfilter.assignment.BooleanAssignmentInfos; import org.gridsuite.modification.server.dto.byfilter.assignment.DoubleAssignmentInfos; +import org.gridsuite.modification.server.dto.byfilter.equipmentfield.GeneratorField; import org.junit.Test; import org.junit.jupiter.api.Tag; @@ -61,20 +60,6 @@ public void testCreateWithWarning() throws Exception { assertEquals(55, getNetwork().getGenerator(GENERATOR_ID_1).getTargetP(), 0); } - @Test - public void testWithNullValue() throws Exception { - IdentifierListFilterEquipmentAttributes identifiableAttributes = getIdentifiableAttributes(GENERATOR_ID_1, 1.0); - AbstractFilter filterEquipments = getFilterEquipments(FILTER_ID_1, List.of(identifiableAttributes)); - - DoubleAssignmentInfos simpleInfos = DoubleAssignmentInfos.builder() - .filters(List.of(new FilterInfos(FILTER_ID_1, "filter1"))) - .editedField(GeneratorField.ACTIVE_POWER_SET_POINT.name()) - .value(null) - .build(); - - checkCreateWithError(List.of(simpleInfos), List.of(filterEquipments)); - } - protected void createEquipments() { getNetwork().getGenerator(GENERATOR_ID_1) .setTargetP(100)