Skip to content

Commit 4400125

Browse files
committed
Fix some tests and style.
Signed-off-by: Bertrand Rix <[email protected]>
1 parent 73e369e commit 4400125

File tree

9 files changed

+12
-15
lines changed

9 files changed

+12
-15
lines changed

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/AbstractNetwork.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.powsybl.network.store.iidm.impl;
22

3-
import com.google.common.collect.ImmutableList;
43
import com.powsybl.iidm.network.*;
54
import com.powsybl.network.store.model.IdentifiableAttributes;
65
import com.powsybl.network.store.model.Resource;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/NetworkImpl.java

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import com.google.common.collect.ImmutableList;
1010
import com.google.common.collect.Lists;
11-
import com.google.common.collect.Multimap;
1211
import com.google.common.primitives.Ints;
1312
import com.powsybl.cgmes.extensions.*;
1413
import com.powsybl.commons.PowsyblException;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/NetworkObjectIndex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ void merge(NetworkObjectIndex other) {
13671367
for (var generatorResource : other.generatorCache.allResourcesGetter.get()) {
13681368
this.createGenerator(generatorResource);
13691369
}
1370-
for (var batteryResource: other.batteryCache.allResourcesGetter.get()) {
1370+
for (var batteryResource : other.batteryCache.allResourcesGetter.get()) {
13711371
this.createBattery(batteryResource);
13721372
}
13731373
for (var shuntResource : other.shuntCompensatorCache.allResourcesGetter.get()) {

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/NetworkStoreClient.java

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package com.powsybl.network.store.iidm.impl;
99

1010
import com.powsybl.network.store.model.*;
11-
import org.openxmlformats.schemas.drawingml.x2006.chart.STHoleSizeUByte;
1211

1312
import java.util.List;
1413
import java.util.Optional;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/SubnetworkImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Stream<VoltageLevel> getVoltageLevelStream() {
6363

6464
@Override
6565
public int getVoltageLevelCount() {
66-
return (int)getVoltageLevelStream().count();
66+
return (int) getVoltageLevelStream().count();
6767
}
6868

6969
@Override
@@ -531,13 +531,13 @@ public Network detach() {
531531

532532
// Move the substations and voltageLevels to the new network
533533
//ref.setRef(new RefObj<>(null));
534-
for(Substation substation : getSubstations()) {
534+
for (Substation substation : getSubstations()) {
535535
SubstationImpl impl = (SubstationImpl) substation;
536536
Resource< SubstationAttributes> attributes = impl.getResource();
537537
detachedNetwork.index.createSubstation(attributes);
538538
index.removeSubstation(attributes.getId());
539539
}
540-
for(VoltageLevel vl : getVoltageLevels()) {
540+
for (VoltageLevel vl : getVoltageLevels()) {
541541
VoltageLevelImpl impl = (VoltageLevelImpl) vl;
542542
Resource<VoltageLevelAttributes> attributes = impl.getResource();
543543
detachedNetwork.index.createVoltageLevel(attributes);

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/VoltageLevelAdderImpl.java

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class VoltageLevelAdderImpl extends AbstractIdentifiableAdder<VoltageLevelAdderI
4141
this.substationResource = substationResource;
4242
}
4343

44-
4544
@Override
4645
public VoltageLevelAdder setNominalV(double nominalV) {
4746
this.nominalV = nominalV;

network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/CreateNetworksUtil.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ static Network createBusBreakerNetworkWithOneBus(String networkSuffix) {
637637
static Network createBusBreakerNetworkWithTwoBuses() {
638638
return createBusBreakerNetworkWithTwoBuses("");
639639
}
640+
640641
static Network createBusBreakerNetworkWithTwoBuses(String networkSuffix) {
641642
Network network = createBusBreakerNetworkWithOneBus(networkSuffix);
642643
VoltageLevel vl1 = network.getVoltageLevel("VL1" + networkSuffix);
@@ -645,7 +646,7 @@ static Network createBusBreakerNetworkWithTwoBuses(String networkSuffix) {
645646
.add();
646647
vl1.getBusBreakerView().newSwitch()
647648
.setId("BR1" + networkSuffix)
648-
.setBus1("B2" + networkSuffix)
649+
.setBus1("B2" + networkSuffix)
649650
.setBus2("B1" + networkSuffix)
650651
.setOpen(false)
651652
.add();
@@ -739,7 +740,7 @@ static Network createBusBreakerNetworkWithLine(String networkSuffix) {
739740
.setId("B21" + networkSuffix)
740741
.add();
741742
vl2.newGenerator()
742-
.setId("G2" + networkSuffix)
743+
.setId("G2" + networkSuffix)
743744
.setBus("B21" + networkSuffix)
744745
.setMaxP(100.0)
745746
.setMinP(50.0)

network-store-model/src/test/java/com/powsybl/network/store/model/ResourceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void networkTest() throws IOException {
3838
ObjectMapper objectMapper = new ObjectMapper();
3939
objectMapper.registerModule(new JodaModule());
4040
String json = objectMapper.writeValueAsString(resource);
41-
assertEquals("{\"type\":\"NETWORK\",\"id\":\"foo\",\"variantNum\":0,\"attributes\":{\"uuid\":\"7928181c-7977-4592-ba19-88027e4254e4\",\"fictitious\":false,\"caseDate\":1420070400000,\"forecastDistance\":0,\"connectedComponentsValid\":false,\"synchronousComponentsValid\":false}}", json);
41+
assertEquals("{\"type\":\"NETWORK\",\"id\":\"foo\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"uuid\":\"7928181c-7977-4592-ba19-88027e4254e4\",\"fictitious\":false,\"caseDate\":1420070400000,\"forecastDistance\":0,\"connectedComponentsValid\":false,\"synchronousComponentsValid\":false}}", json);
4242
Resource<NetworkAttributes> resource2 = objectMapper.readValue(json, new TypeReference<Resource<NetworkAttributes>>() { });
4343
assertNotNull(resource2);
4444
assertEquals("foo", resource2.getId());
@@ -61,7 +61,7 @@ public void substationTest() throws IOException {
6161
ObjectMapper objectMapper = JsonUtil.createObjectMapper();
6262
String json = objectMapper.writeValueAsString(resource);
6363

64-
String jsonRef = "{\"type\":\"SUBSTATION\",\"id\":\"S\",\"variantNum\":0,\"attributes\":{\"name\":\"SS\",\"fictitious\":false,\"country\":\"FR\",\"tso\":\"RTE\"}}";
64+
String jsonRef = "{\"type\":\"SUBSTATION\",\"id\":\"S\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"name\":\"SS\",\"fictitious\":false,\"country\":\"FR\",\"tso\":\"RTE\"}}";
6565
assertEquals(jsonRef, json);
6666

6767
Resource<SubstationAttributes> resource2 = objectMapper.readValue(json, new TypeReference<Resource<SubstationAttributes>>() { });

network-store-model/src/test/java/com/powsybl/network/store/model/TopLevelDocumentTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void test() throws IOException {
3434
TopLevelDocument document = TopLevelDocument.of(resource);
3535
ObjectMapper objectMapper = JsonUtil.createObjectMapper();
3636
String json = objectMapper.writeValueAsString(document);
37-
String jsonRef = "{\"data\":[{\"type\":\"SUBSTATION\",\"id\":\"S\",\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}}],\"meta\":{}}";
37+
String jsonRef = "{\"data\":[{\"type\":\"SUBSTATION\",\"id\":\"S\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}}],\"meta\":{}}";
3838
assertEquals(jsonRef, json);
3939
TopLevelDocument document2 = objectMapper.readValue(json, TopLevelDocument.class);
4040
assertEquals(resource, document2.getData().get(0));
@@ -51,7 +51,7 @@ public void testMultiResources() throws IOException {
5151
TopLevelDocument document = TopLevelDocument.of(ImmutableList.of(resource, resource));
5252
ObjectMapper objectMapper = JsonUtil.createObjectMapper();
5353
String json = objectMapper.writeValueAsString(document);
54-
String jsonRef = "{\"data\":[{\"type\":\"SUBSTATION\",\"id\":\"S\",\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}},{\"type\":\"SUBSTATION\",\"id\":\"S\",\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}}],\"meta\":{}}";
54+
String jsonRef = "{\"data\":[{\"type\":\"SUBSTATION\",\"id\":\"S\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}},{\"type\":\"SUBSTATION\",\"id\":\"S\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"fictitious\":false,\"country\":\"FR\"}}],\"meta\":{}}";
5555
assertEquals(jsonRef, json);
5656
TopLevelDocument document2 = objectMapper.readValue(json, TopLevelDocument.class);
5757
assertEquals(2, document2.getData().size());
@@ -85,7 +85,7 @@ public void testGenerator() throws IOException {
8585
TopLevelDocument document = TopLevelDocument.of(resourceGenerator);
8686
ObjectMapper objectMapper = JsonUtil.createObjectMapper();
8787
String json = objectMapper.writeValueAsString(document);
88-
String jsonRef = "{\"data\":[{\"type\":\"GENERATOR\",\"id\":\"gen1\",\"variantNum\":0,\"attributes\":{\"voltageLevelId\":\"vl1\",\"name\":\"name\",\"fictitious\":false,\"node\":1,\"bus\":\"bus1\",\"energySource\":\"HYDRO\",\"minP\":2.0,\"maxP\":1.0,\"voltageRegulatorOn\":false,\"targetP\":3.0,\"targetQ\":0.0,\"targetV\":4.0,\"ratedS\":0.0,\"p\":NaN,\"q\":NaN,\"regulatingTerminal\":{\"connectableId\":\"idEq\",\"side\":\"ONE\"}}}],\"meta\":{}}";
88+
String jsonRef = "{\"data\":[{\"type\":\"GENERATOR\",\"id\":\"gen1\",\"parentNetwork\":null,\"variantNum\":0,\"attributes\":{\"voltageLevelId\":\"vl1\",\"name\":\"name\",\"fictitious\":false,\"node\":1,\"bus\":\"bus1\",\"energySource\":\"HYDRO\",\"minP\":2.0,\"maxP\":1.0,\"voltageRegulatorOn\":false,\"targetP\":3.0,\"targetQ\":0.0,\"targetV\":4.0,\"ratedS\":0.0,\"p\":NaN,\"q\":NaN,\"regulatingTerminal\":{\"connectableId\":\"idEq\",\"side\":\"ONE\"}}}],\"meta\":{}}";
8989
assertEquals(jsonRef, json);
9090
TopLevelDocument document2 = objectMapper.readValue(json, TopLevelDocument.class);
9191
assertEquals(resourceGenerator, document2.getData().get(0));

0 commit comments

Comments
 (0)