Skip to content

Commit

Permalink
fix more unit test
Browse files Browse the repository at this point in the history
Signed-off-by: jamal-khey <[email protected]>
  • Loading branch information
jamal-khey committed Oct 15, 2023
1 parent 5f0555c commit 731b577
Show file tree
Hide file tree
Showing 54 changed files with 149 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private void assignAttributes(ConverterStationCreationInfos converterStationCrea

public ConverterStationCreationInfos toConverterStationInfos() {
return ConverterStationCreationInfos.builder()
.stashed(getStashed())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.lossFactor(getLossFactor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void update(ModificationInfos modificationInfos) {
}

private void assignAttributes(LineCreationInfos lineCreationInfos) {
setStashed(lineCreationInfos.getStashed());
shuntConductance1 = lineCreationInfos.getShuntConductance1();
shuntSusceptance1 = lineCreationInfos.getShuntSusceptance1();
shuntConductance2 = lineCreationInfos.getShuntConductance2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public VoltageLevelCreationInfos toModificationInfos() {
}

public VoltageLevelCreationInfos toVoltageLevelCreationInfos() {
return toVoltageLevelCreationInfosBuilder().build();
return toVoltageLevelCreationInfosBuilder().stashed(false).build();
}

private VoltageLevelCreationInfos.VoltageLevelCreationInfosBuilder<?, ?> toVoltageLevelCreationInfosBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void update(@NonNull ModificationInfos modificationInfos) {
}

private void assignAttributes(VscCreationInfos vscCreationInfos) {
this.setStashed(vscCreationInfos.getStashed());
this.activePower = vscCreationInfos.getActivePower();
this.angleDroopActivePowerControl = vscCreationInfos.getAngleDroopActivePowerControl();
this.droop = vscCreationInfos.getDroop();
Expand All @@ -115,7 +116,6 @@ public VscCreationInfos toModificationInfos() {
private VscCreationInfos.VscCreationInfosBuilder<?, ?> toVscCreationInfosBuilder() {
ConverterStationCreationInfos converterStationCreationInfos1 = getConverterStation1() == null ? null : getConverterStation1().toConverterStationInfos();
ConverterStationCreationInfos converterStationCreationInfos2 = getConverterStation2() == null ? null : getConverterStation2().toConverterStationInfos();

return VscCreationInfos.builder()
.uuid(getId())
.date(getDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void update(@NonNull ModificationInfos modificationInfos) {
}

private void assignAttributes(LineSplitWithVoltageLevelInfos splitWithVoltageLevelInfos) {
setStashed(splitWithVoltageLevelInfos.getStashed());
lineToSplitId = splitWithVoltageLevelInfos.getLineToSplitId();
percent = splitWithVoltageLevelInfos.getPercent();
mayVoltageLevelCreation = null; // Need for the update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BatteryCreationInfos.builder()
.stashed(false)
.equipmentId("idBattery2")
.equipmentName("nameBattery2")
.voltageLevelId("v1")
Expand All @@ -60,6 +61,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return BatteryCreationInfos.builder()
.stashed(false)
.equipmentId("idBattery2")
.equipmentName("nameBatteryModified")
.voltageLevelId("v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected Network createNetwork(UUID networkUuid) {
protected ModificationInfos buildModification() {
// create new battery in voltage level with node/breaker topology (in voltage level "v2" and busbar section "1B")
return BatteryCreationInfos.builder()
.stashed(false)
.equipmentId("idBattery1")
.equipmentName("idBattery1")
.voltageLevelId("v2")
Expand All @@ -65,6 +66,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return BatteryCreationInfos.builder()
.stashed(false)
.equipmentId("idBattery2")
.equipmentName("nameBatteryModified")
.voltageLevelId("v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BatteryModificationInfos.builder()
.stashed(false)
.equipmentId("v3Battery")
.equipmentName(new AttributeModification<>("newV1Battery", OperationType.SET))
.activePowerSetpoint(new AttributeModification<>(80.0, OperationType.SET))
Expand All @@ -59,6 +60,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return BatteryModificationInfos.builder()
.stashed(false)
.equipmentId("idBattery")
.equipmentName(new AttributeModification<>("newV1BatteryEdited", OperationType.SET))
.activePowerSetpoint(new AttributeModification<>(81.0, OperationType.SET))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_LINE_ID)
.energizedVoltageLevelId("vl1")
.action(BranchStatusModificationInfos.ActionType.ENERGISE_END_ONE).build();
Expand All @@ -51,6 +52,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId("line1")
.energizedVoltageLevelId("vl1_bis")
.action(BranchStatusModificationInfos.ActionType.TRIP).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_LINE_ID)
.energizedVoltageLevelId("vl2")
.action(BranchStatusModificationInfos.ActionType.ENERGISE_END_TWO).build();
Expand All @@ -51,6 +52,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId("line1")
.energizedVoltageLevelId("vl2_bis")
.action(BranchStatusModificationInfos.ActionType.TRIP).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_LINE_ID)
.action(BranchStatusModificationInfos.ActionType.LOCKOUT).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(UPDATE_BRANCH_ID)
.action(BranchStatusModificationInfos.ActionType.SWITCH_ON).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_LINE_ID)
.action(BranchStatusModificationInfos.ActionType.SWITCH_ON).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId("line1")
.action(BranchStatusModificationInfos.ActionType.TRIP).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_BRANCH_ID)
.action(BranchStatusModificationInfos.ActionType.TRIP).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(UPDATE_BRANCH_ID)
.action(BranchStatusModificationInfos.ActionType.SWITCH_ON).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_LINE_ID)
.action(BranchStatusModificationInfos.ActionType.TRIP).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return BranchStatusModificationInfos.builder()
.stashed(false)
.equipmentId(UPDATE_BRANCH_ID)
.action(BranchStatusModificationInfos.ActionType.SWITCH_ON).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return DeleteAttachingLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("l2")
.attachedLineId("l3")
Expand All @@ -51,6 +52,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return DeleteAttachingLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("l2")
.attachedLineId("l3")
Expand All @@ -77,6 +79,7 @@ protected void assertAfterNetworkModificationDeletion() {
public void createWithInvalidLineIdTest() throws Exception {
// test create with incorrect line id
DeleteAttachingLineInfos deleteAttachingLineInfos = DeleteAttachingLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("ll")
.attachedLineId("l2")
Expand All @@ -93,6 +96,7 @@ public void createWithInvalidLineIdTest() throws Exception {
@Test
public void createWithNoAttachmentPointTest() throws Exception {
DeleteAttachingLineInfos deleteAttachingLineInfos = DeleteAttachingLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("l3")
.attachedLineId("l1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return DeleteVoltageLevelOnLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("l2")
.replacingLine1Id("replacementLineId")
Expand All @@ -50,6 +51,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return DeleteVoltageLevelOnLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("line00")
.lineToAttachTo2Id("line11")
.replacingLine1Id("replacingLineId2")
Expand Down Expand Up @@ -79,6 +81,7 @@ protected void assertAfterNetworkModificationDeletion() {
public void createWithInvalidLineIdTest() throws Exception {
// test create with incorrect line id
DeleteVoltageLevelOnLineInfos deleteVoltageLevelOnLineInfos = DeleteVoltageLevelOnLineInfos.builder()
.stashed(false)
.lineToAttachTo1Id("l1")
.lineToAttachTo2Id("ll")
.replacingLine1Id("replacementLineId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ public void testEquipmentAttributeModificationInfos() throws Exception {
UUID modificationUuid = UUID.randomUUID();
//We need to limit the precision to avoid database precision storage limit issue (postgres has a precision of 6 digits while h2 can go to 9)
EquipmentAttributeModificationInfos modificationInfos = EquipmentAttributeModificationInfos.builder()
.stashed(false)
.uuid(modificationUuid)
.date(ZonedDateTime.of(2021, 2, 19, 0, 0, 0, 0, ZoneOffset.UTC).truncatedTo(ChronoUnit.MICROS))
.equipmentId("equipmentId")
.equipmentAttributeName("equipmentAttributeName")
.equipmentAttributeValue("equipmentAttributeValue")
.equipmentType(IdentifiableType.VOLTAGE_LEVEL)
.build();
assertEquals(String.format("EquipmentAttributeModificationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=%s, date=2021-02-19T00:00Z, stashed=null), equipmentId=equipmentId), equipmentAttributeName=equipmentAttributeName, equipmentAttributeValue=equipmentAttributeValue, equipmentType=VOLTAGE_LEVEL)", modificationUuid), modificationInfos.toString());
assertEquals(String.format("EquipmentAttributeModificationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=%s, date=2021-02-19T00:00Z, stashed=false), equipmentId=equipmentId), equipmentAttributeName=equipmentAttributeName, equipmentAttributeValue=equipmentAttributeValue, equipmentType=VOLTAGE_LEVEL)", modificationUuid), modificationInfos.toString());

EquipmentAttributeModificationInfos switchStatusModificationInfos = EquipmentAttributeModificationInfos.builder()
.stashed(false)
.equipmentType(IdentifiableType.SWITCH)
.equipmentAttributeName("open")
.equipmentAttributeValue(true)
Expand Down Expand Up @@ -128,6 +130,7 @@ private void switchModifications(String extraParams, String switchId1, String sw
public void testWithErrors() throws Exception {
// bad equipment attribute name
EquipmentAttributeModificationInfos switchStatusModificationInfos = EquipmentAttributeModificationInfos.builder()
.stashed(false)
.equipmentType(IdentifiableType.SWITCH)
.equipmentAttributeName("close") // bad
.equipmentAttributeValue(true)
Expand Down Expand Up @@ -158,6 +161,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected EquipmentAttributeModificationInfos buildModification() {
return EquipmentAttributeModificationInfos.builder()
.stashed(false)
.equipmentType(IdentifiableType.SWITCH)
.equipmentAttributeName("open")
.equipmentAttributeValue(true)
Expand All @@ -168,6 +172,7 @@ protected EquipmentAttributeModificationInfos buildModification() {
@Override
protected EquipmentAttributeModificationInfos buildModificationUpdate() {
return EquipmentAttributeModificationInfos.builder()
.stashed(false)
.equipmentType(IdentifiableType.SWITCH)
.equipmentAttributeName("open")
.equipmentAttributeValue(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return EquipmentDeletionInfos.builder()
.stashed(false)
.equipmentType("LOAD")
.equipmentId("v1load")
.build();
Expand All @@ -56,6 +57,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return EquipmentDeletionInfos.builder()
.stashed(false)
.equipmentType("GENERATOR")
.equipmentId("idGenerator")
.build();
Expand All @@ -75,6 +77,7 @@ protected void assertAfterNetworkModificationDeletion() {
public void testOkWhenRemovingIsolatedEquipment() throws Exception {

EquipmentDeletionInfos equipmentDeletionInfos = EquipmentDeletionInfos.builder()
.stashed(false)
.equipmentType("LOAD")
.equipmentId("v5load")
.build();
Expand Down Expand Up @@ -115,6 +118,7 @@ private void deleteHvdcLineWithShuntCompensator(String shuntNameToBeRemoved, boo
new HvdcLccDeletionInfos(shuntData, null) :
new HvdcLccDeletionInfos(null, shuntData);
EquipmentDeletionInfos equipmentDeletionInfos = EquipmentDeletionInfos.builder()
.stashed(false)
.equipmentType("HVDC_LINE")
.equipmentId(hvdcLineName)
.equipmentInfos(hvdcLccDeletionInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return GenerationDispatchInfos.builder()
.stashed(false)
.lossCoefficient(20.)
.defaultOutageRate(0.)
.generatorsWithoutOutage(List.of())
Expand All @@ -577,6 +578,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return GenerationDispatchInfos.builder()
.stashed(false)
.lossCoefficient(50.)
.defaultOutageRate(25.)
.generatorsWithoutOutage(List.of(GeneratorsFilterInfos.builder().id(UUID.randomUUID()).name("name1").build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return GeneratorCreationInfos.builder()
.stashed(false)
.equipmentId("idGenerator2")
.equipmentName("nameGenerator2")
.voltageLevelId("v1")
Expand Down Expand Up @@ -76,6 +77,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return GeneratorCreationInfos.builder()
.stashed(false)
.equipmentId("idGenerator2")
.equipmentName("nameGeneratorModified")
.voltageLevelId("v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected Network createNetwork(UUID networkUuid) {
protected ModificationInfos buildModification() {
// create new generator in voltage level with node/breaker topology (in voltage level "v2" and busbar section "1B")
return GeneratorCreationInfos.builder()
.stashed(false)
.equipmentId("idGenerator1")
.equipmentName("idGenerator1")
.voltageLevelId("v2")
Expand Down Expand Up @@ -80,6 +81,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return GeneratorCreationInfos.builder()
.stashed(false)
.equipmentId("idGenerator2")
.equipmentName("nameGeneratorModified")
.voltageLevelId("v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected Network createNetwork(UUID networkUuid) {
@Override
protected ModificationInfos buildModification() {
return GeneratorModificationInfos.builder()
.stashed(false)
.equipmentId("idGenerator")
.energySource(new AttributeModification<>(EnergySource.SOLAR, OperationType.SET))
.equipmentName(new AttributeModification<>("newV1Generator", OperationType.SET))
Expand Down Expand Up @@ -77,6 +78,7 @@ protected ModificationInfos buildModification() {
@Override
protected ModificationInfos buildModificationUpdate() {
return GeneratorModificationInfos.builder()
.stashed(false)
.equipmentId("idGenerator")
.energySource(new AttributeModification<>(EnergySource.HYDRO, OperationType.SET))
.equipmentName(new AttributeModification<>("newV1GeneratorEdited", OperationType.SET))
Expand Down
Loading

0 comments on commit 731b577

Please sign in to comment.