Skip to content

Commit

Permalink
Enhance test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Aug 23, 2024
1 parent f3f5a71 commit 8e8d8f6
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import java.util.Map;
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;
import static org.gridsuite.modification.server.NetworkModificationException.Type.*;
import static org.gridsuite.modification.server.modifications.VscCreation.ACTIVE_POWER_CONTROL_EXTENSION_CREATE_ERROR_MESSAGE;
import static org.gridsuite.modification.server.modifications.VscModification.DROOP_AND_P0_FIELD;
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down Expand Up @@ -298,4 +301,34 @@ public void testCreateWithErrors() throws Exception {
assertLogMessage(new NetworkModificationException(HVDC_LINE_ALREADY_EXISTS, "hvdcLine").getMessage(),
vscCreationInfos.getErrorType().name(), reportService);
}

@Test
public void testCreateWithoutEnablingDroopPowerControl() throws Exception {
// create without enabling droop power control
VscCreationInfos vscCreationInfos = (VscCreationInfos) buildModification();
vscCreationInfos.setAngleDroopActivePowerControl(false);
String vscCreationInfosJson = mapper.writeValueAsString(vscCreationInfos);
mockMvc.perform(post(getNetworkModificationUri()).content(vscCreationInfosJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
assertThat(getNetwork().getHvdcLine("vsc1")).isNotNull();
HvdcLine hvdcLine = getNetwork().getHvdcLine("vsc1");
assertThat(hvdcLine).isNotNull();
HvdcAngleDroopActivePowerControl activePowerControl = hvdcLine.getExtension(HvdcAngleDroopActivePowerControl.class);
assertThat(activePowerControl).isNull();
}

@Test
public void testCreateWithEnablingDroopPowerControl() throws Exception {
// create with enabling droop power control but not provide Droop and P0
VscCreationInfos vscCreationInfos = (VscCreationInfos) buildModification();
vscCreationInfos.setAngleDroopActivePowerControl(true);
vscCreationInfos.setDroop(null);
vscCreationInfos.setP0(null);
String vscCreationInfosJson = mapper.writeValueAsString(vscCreationInfos);
mockMvc.perform(post(getNetworkModificationUri()).content(vscCreationInfosJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
assertLogMessage(new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL,
String.format(ACTIVE_POWER_CONTROL_EXTENSION_CREATE_ERROR_MESSAGE, DROOP_AND_P0_FIELD)).getMessage(),
vscCreationInfos.getErrorType().name(), reportService);
}
}

0 comments on commit 8e8d8f6

Please sign in to comment.