Skip to content

Commit 709f564

Browse files
authored
Merge branch 'dev' into ns/#81-develop-a-validation-strategy
2 parents 08662b2 + 375a2dd commit 709f564

File tree

9 files changed

+315
-24
lines changed

9 files changed

+315
-24
lines changed

docs/readthedocs/models/input/participant/evcs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Limitations
111111
"""""""""""
112112

113113
- the available charging types are currently limited to only some common standard charging point types and not configurable
114-
via a type file or table. Although providing custom types is possible using the syntax explained above.
114+
via a type file or table. Nevertheless, providing custom types is possible using the syntax explained above.
115115
If there is additional need for a more granular type configuration via type file please contact us.
116116
- each charging station can hold one or more charging points. If more than one charging point is available
117117
all attributes (e.g. :code:`sRated` or :code:`connectionType`) are considered to be equal for all connection

src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.UUID;
1414
import javax.measure.quantity.Temperature;
1515
import javax.measure.quantity.Volume;
16-
import org.apache.commons.lang3.NotImplementedException;
1716
import tech.units.indriya.ComparableQuantity;
1817

1918
/** Thermal storage with cylindrical shape */
@@ -107,10 +106,8 @@ public ComparableQuantity<SpecificHeatCapacity> getC() {
107106
return c;
108107
}
109108

110-
@Override
111-
public UniqueEntityBuilder copy() {
112-
throw new NotImplementedException(
113-
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
109+
public CylindricalStorageInputCopyBuilder copy() {
110+
return new CylindricalStorageInputCopyBuilder(this);
114111
}
115112

116113
@Override
@@ -157,4 +154,76 @@ public String toString() {
157154
+ c
158155
+ '}';
159156
}
157+
158+
/**
159+
* A builder pattern based approach to create copies of {@link CylindricalStorageInput} entities
160+
* with altered field values. For detailed field descriptions refer to java docs of {@link
161+
* CylindricalStorageInput}
162+
*/
163+
public static class CylindricalStorageInputCopyBuilder
164+
extends ThermalUnitInput.ThermalUnitInputCopyBuilder<CylindricalStorageInputCopyBuilder> {
165+
166+
private ComparableQuantity<Volume> storageVolumeLvl;
167+
private ComparableQuantity<Volume> storageVolumeLvlMin;
168+
private ComparableQuantity<Temperature> inletTemp;
169+
private ComparableQuantity<Temperature> returnTemp;
170+
private ComparableQuantity<SpecificHeatCapacity> c;
171+
172+
private CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) {
173+
super(entity);
174+
this.storageVolumeLvl = entity.getStorageVolumeLvl();
175+
this.storageVolumeLvlMin = entity.getStorageVolumeLvlMin();
176+
this.inletTemp = entity.getInletTemp();
177+
this.returnTemp = entity.getReturnTemp();
178+
this.c = entity.getC();
179+
}
180+
181+
@Override
182+
public CylindricalStorageInput build() {
183+
return new CylindricalStorageInput(
184+
getUuid(),
185+
getId(),
186+
getOperator(),
187+
getOperationTime(),
188+
getThermalBus(),
189+
storageVolumeLvl,
190+
storageVolumeLvlMin,
191+
inletTemp,
192+
returnTemp,
193+
c);
194+
}
195+
196+
public CylindricalStorageInputCopyBuilder storageVolumeLvl(
197+
ComparableQuantity<Volume> storageVolumeLvl) {
198+
this.storageVolumeLvl = storageVolumeLvl;
199+
return this;
200+
}
201+
202+
public CylindricalStorageInputCopyBuilder storageVolumeLvlMin(
203+
ComparableQuantity<Volume> storageVolumeLvlMin) {
204+
this.storageVolumeLvlMin = storageVolumeLvlMin;
205+
return this;
206+
}
207+
208+
public CylindricalStorageInputCopyBuilder inletTemp(ComparableQuantity<Temperature> inletTemp) {
209+
this.inletTemp = inletTemp;
210+
return this;
211+
}
212+
213+
public CylindricalStorageInputCopyBuilder returnTemp(
214+
ComparableQuantity<Temperature> returnTemp) {
215+
this.returnTemp = returnTemp;
216+
return this;
217+
}
218+
219+
public CylindricalStorageInputCopyBuilder c(ComparableQuantity<SpecificHeatCapacity> c) {
220+
this.c = c;
221+
return this;
222+
}
223+
224+
@Override
225+
protected CylindricalStorageInputCopyBuilder childInstance() {
226+
return this;
227+
}
228+
}
160229
}

src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalBusInput.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import edu.ie3.datamodel.models.input.AssetInput;
1010
import edu.ie3.datamodel.models.input.OperatorInput;
1111
import java.util.UUID;
12-
import org.apache.commons.lang3.NotImplementedException;
1312

1413
/** A thermal bus, to which different {@link ThermalUnitInput} units may be connected */
1514
public class ThermalBusInput extends AssetInput {
@@ -36,9 +35,30 @@ public ThermalBusInput(UUID uuid, String id) {
3635
super(uuid, id);
3736
}
3837

39-
@Override
40-
public UniqueEntityBuilder copy() {
41-
throw new NotImplementedException(
42-
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
38+
public ThermalBusInputCopyBuilder copy() {
39+
return new ThermalBusInputCopyBuilder(this);
40+
}
41+
42+
/**
43+
* A builder pattern based approach to create copies of {@link ThermalBusInput} entities with
44+
* altered field values. For detailed field descriptions refer to java docs of {@link
45+
* ThermalBusInput}
46+
*/
47+
public static class ThermalBusInputCopyBuilder
48+
extends AssetInput.AssetInputCopyBuilder<ThermalBusInputCopyBuilder> {
49+
50+
private ThermalBusInputCopyBuilder(ThermalBusInput entity) {
51+
super(entity);
52+
}
53+
54+
@Override
55+
public ThermalBusInput build() {
56+
return new ThermalBusInput(getUuid(), getId(), getOperator(), getOperationTime());
57+
}
58+
59+
@Override
60+
protected ThermalBusInputCopyBuilder childInstance() {
61+
return this;
62+
}
4363
}
4464
}

src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import edu.ie3.util.quantities.interfaces.ThermalConductance;
1313
import java.util.Objects;
1414
import java.util.UUID;
15-
import org.apache.commons.lang3.NotImplementedException;
1615
import tech.units.indriya.ComparableQuantity;
1716

1817
/** Quite simple thermal model of a house to serve as a heat sink */
@@ -70,10 +69,8 @@ public ComparableQuantity<HeatCapacity> getEthCapa() {
7069
return ethCapa;
7170
}
7271

73-
@Override
74-
public UniqueEntityBuilder copy() {
75-
throw new NotImplementedException(
76-
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
72+
public ThermalHouseInputCopyBuilder copy() {
73+
return new ThermalHouseInputCopyBuilder(this);
7774
}
7875

7976
@Override
@@ -109,4 +106,50 @@ public String toString() {
109106
+ ethCapa
110107
+ '}';
111108
}
109+
110+
/**
111+
* A builder pattern based approach to create copies of {@link ThermalHouseInput} entities with
112+
* altered field values. For detailed field descriptions refer to java docs of {@link
113+
* ThermalHouseInput}
114+
*/
115+
public static class ThermalHouseInputCopyBuilder
116+
extends ThermalUnitInput.ThermalUnitInputCopyBuilder<ThermalHouseInputCopyBuilder> {
117+
118+
private ComparableQuantity<ThermalConductance> ethLosses;
119+
private ComparableQuantity<HeatCapacity> ethCapa;
120+
121+
private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) {
122+
super(entity);
123+
this.ethLosses = entity.getEthLosses();
124+
this.ethCapa = entity.getEthCapa();
125+
}
126+
127+
@Override
128+
public ThermalHouseInput build() {
129+
return new ThermalHouseInput(
130+
getUuid(),
131+
getId(),
132+
getOperator(),
133+
getOperationTime(),
134+
getThermalBus(),
135+
ethLosses,
136+
ethCapa);
137+
}
138+
139+
public ThermalHouseInputCopyBuilder ethLosses(
140+
ComparableQuantity<ThermalConductance> ethLosses) {
141+
this.ethLosses = ethLosses;
142+
return this;
143+
}
144+
145+
public ThermalHouseInputCopyBuilder ethCapa(ComparableQuantity<HeatCapacity> ethCapa) {
146+
this.ethCapa = ethCapa;
147+
return this;
148+
}
149+
150+
@Override
151+
protected ThermalHouseInputCopyBuilder childInstance() {
152+
return this;
153+
}
154+
}
112155
}

src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalUnitInput.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,35 @@ public String toString() {
7878
+ thermalBus.getUuid()
7979
+ '}';
8080
}
81+
82+
/**
83+
* Abstract class for all builders that build child entities of abstract class {@link
84+
* ThermalUnitInput}
85+
*/
86+
protected abstract static class ThermalUnitInputCopyBuilder<
87+
T extends ThermalUnitInput.ThermalUnitInputCopyBuilder<T>>
88+
extends AssetInputCopyBuilder<T> {
89+
90+
private ThermalBusInput thermalBus;
91+
92+
protected ThermalUnitInputCopyBuilder(ThermalUnitInput entity) {
93+
super(entity);
94+
this.thermalBus = entity.getThermalBus();
95+
}
96+
97+
public T thermalBus(ThermalBusInput thermalBus) {
98+
this.thermalBus = thermalBus;
99+
return childInstance();
100+
}
101+
102+
protected ThermalBusInput getThermalBus() {
103+
return thermalBus;
104+
}
105+
106+
@Override
107+
public abstract ThermalUnitInput build();
108+
109+
@Override
110+
protected abstract T childInstance();
111+
}
81112
}

src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ import tech.units.indriya.quantity.Quantities
1818

1919
import javax.measure.quantity.Dimensionless
2020
import java.time.ZonedDateTime
21-
2221
/**
23-
* //ToDo: Class Description
22+
* Testing EvcsInputFactory
2423
*
2524
* @version 0.1* @since 26.07.20
2625
*/
27-
class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
26+
class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
2827

29-
def "A CsInputFactory should contain exactly the expected class for parsing"() {
28+
def "A EvcsInputFactory should contain exactly the expected class for parsing"() {
3029
given:
3130
def inputFactory = new EvcsInputFactory()
3231
def expectedClasses = [EvcsInput]
@@ -35,7 +34,7 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
3534
inputFactory.supportedClasses == Arrays.asList(expectedClasses.toArray())
3635
}
3736

38-
def "A CsInputFactory should parse a valid CsInput correctly"() {
37+
def "A EvcsInputFactory should parse a valid EvcsInput correctly"() {
3938
given: "a system participant input type factory and model data"
4039
def inputFactory = new EvcsInputFactory()
4140
Map<String, String> parameter = [
@@ -44,9 +43,9 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
4443
"operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]",
4544
"id" : "TestID",
4645
"qcharacteristics": "cosPhiFixed:{(0.0,1.0)}",
47-
"type" : "Household",
48-
"chargingpoints" : "4",
49-
"cosphirated" : "0.95",
46+
"type" : "Household",
47+
"chargingpoints" : "4",
48+
"cosphirated" : "0.95",
5049
]
5150
def inputClass = EvcsInput
5251
def nodeInput = Mock(NodeInput)
@@ -79,4 +78,30 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper {
7978
assert cosPhiRated == Double.parseDouble(parameter["cosphirated"])
8079
}
8180
}
81+
82+
def "A EvcsInputFactory should fail when passing an invalid ChargingPointType"() {
83+
given: "a system participant input type factory and model data"
84+
def inputFactory = new EvcsInputFactory()
85+
Map<String, String> parameter = [
86+
"uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
87+
"operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]",
88+
"operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]",
89+
"id" : "TestID",
90+
"qcharacteristics": "cosPhiFixed:{(0.0,1.0)}",
91+
"type" : "-- invalid --",
92+
"chargingpoints" : "4",
93+
"cosphirated" : "0.95",
94+
]
95+
def inputClass = EvcsInput
96+
def nodeInput = Mock(NodeInput)
97+
def operatorInput = Mock(OperatorInput)
98+
99+
when:
100+
Optional<EvcsInput> input = inputFactory.get(
101+
new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput))
102+
103+
then:
104+
// FactoryException is caught in Factory.java. We get an empty Option back
105+
!input.present
106+
}
82107
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* © 2021. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.models.input.thermal
7+
8+
import edu.ie3.test.common.ThermalUnitInputTestData
9+
import spock.lang.Specification
10+
11+
12+
class CylindricalStorageInputTest extends Specification {
13+
14+
def "A CylindricalStorageInput copy method should work as expected"() {
15+
given:
16+
def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput
17+
18+
when:
19+
def alteredUnit = cylindricalStorageInput.copy().storageVolumeLvl(ThermalUnitInputTestData.storageVolumeLvl)
20+
.storageVolumeLvlMin(ThermalUnitInputTestData.storageVolumeLvlMin).inletTemp(ThermalUnitInputTestData.inletTemp)
21+
.returnTemp(ThermalUnitInputTestData.returnTemp).c(ThermalUnitInputTestData.c)
22+
.thermalBus(ThermalUnitInputTestData.thermalBus).build()
23+
24+
25+
then:
26+
alteredUnit.with {
27+
assert uuid == cylindricalStorageInput.uuid
28+
assert id == cylindricalStorageInput.id
29+
assert operator == cylindricalStorageInput.operator
30+
assert operationTime == cylindricalStorageInput.operationTime
31+
assert thermalBus == cylindricalStorageInput.thermalBus
32+
assert storageVolumeLvl == ThermalUnitInputTestData.storageVolumeLvl
33+
assert storageVolumeLvlMin == ThermalUnitInputTestData.storageVolumeLvlMin
34+
assert inletTemp == ThermalUnitInputTestData.inletTemp
35+
assert returnTemp == ThermalUnitInputTestData.returnTemp
36+
assert c == ThermalUnitInputTestData.c
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)