Skip to content

Commit 98414c4

Browse files
committed
add unit test
Signed-off-by: Thang PHAM <[email protected]>
1 parent cb58f05 commit 98414c4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
Copyright (c) 2025, RTE (http://www.rte-france.com)
44
This Source Code Form is subject to the terms of the Mozilla Public
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.

src/main/java/org/gridsuite/dynamicmargincalculation/server/DynamicMarginCalculationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2024, RTE (http://www.rte-france.com)
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.

src/test/java/org/gridsuite/dynamicmargincalculation/server/service/DynamicMarginCalculationResultServiceTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.gridsuite.dynamicmargincalculation.server.service;
99

10+
import org.gridsuite.dynamicmargincalculation.server.DynamicMarginCalculationException;
1011
import org.gridsuite.dynamicmargincalculation.server.dto.DynamicMarginCalculationStatus;
1112
import org.gridsuite.dynamicmargincalculation.server.entities.DynamicMarginCalculationResultEntity;
1213
import org.gridsuite.dynamicmargincalculation.server.repositories.DynamicMarginCalculationResultRepository;
@@ -22,6 +23,7 @@
2223
import java.util.UUID;
2324

2425
import static org.assertj.core.api.Assertions.assertThat;
26+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2527

2628
/**
2729
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
@@ -75,6 +77,17 @@ void testCrud() {
7577
LOGGER.info("Actual updated result status = {}", updatedResultEntityOpt.get().getStatus());
7678
assertThat(updatedResultEntityOpt.get().getStatus()).isSameAs(DynamicMarginCalculationStatus.NOT_DONE);
7779

80+
// --- update entity with non-existing UUID --- //
81+
LOGGER.info("Test update status with non-existing UUID");
82+
UUID nonExistingUuid = UUID.randomUUID();
83+
84+
// should throw DynamicMarginCalculationException since the UUID doesn't exist
85+
assertThatThrownBy(() -> dynamicSecurityAnalysisResultService.updateResult(nonExistingUuid, DynamicMarginCalculationStatus.FAILED))
86+
.isInstanceOf(DynamicMarginCalculationException.class)
87+
.hasMessageContaining("Result uuid not found: " + nonExistingUuid);
88+
89+
LOGGER.info("Non-existing UUID update threw expected exception");
90+
7891
// --- delete result --- //
7992
LOGGER.info("Test delete a result");
8093
dynamicSecurityAnalysisResultService.delete(resultUuid);

0 commit comments

Comments
 (0)