Skip to content

Commit 18bfe03

Browse files
authored
JUnit Test Framework: unify Dummy components (OpenEMS#2421)
1 parent fb6d1dd commit 18bfe03

File tree

65 files changed

+1252
-1726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1252
-1726
lines changed

io.openems.backend.common/src/io/openems/backend/common/uiwebsocket/UiWebsocket.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface UiWebsocket {
1919
* Response.
2020
*
2121
* @param websocketId the id of the UI websocket connection
22-
* @param request the JsonrpcRequest
22+
* @param request the JsonrpcRequest
2323
* @return the JSON-RPC Success Response Future
2424
* @throws OpenemsNamedException on error
2525
*/
@@ -29,7 +29,7 @@ public CompletableFuture<JsonrpcResponseSuccess> send(UUID websocketId, JsonrpcR
2929
/**
3030
* Send a JSON-RPC Notification to a UI session.
3131
*
32-
* @param websocketId the id of the UI websocket connection
32+
* @param websocketId the id of the UI websocket connection
3333
* @param notification the JsonrpcNotification
3434
* @throws OpenemsNamedException on error
3535
*/

io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/MyUser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class MyUser extends User {
1010

1111
private final int odooId;
12-
12+
1313
public MyUser(int odooId, String login, String name, String token, Language language, Role globalRole,
1414
NavigableMap<String, Role> roles, boolean hasMultipleEdges) {
1515
super(login, name, token, language, globalRole, roles, hasMultipleEdges);

io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/odoo/OdooHandler.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ private Map<String, Object> updateCompany(MyUser user, JsonObject companyJson) t
400400
* @throws OpenemsNamedException on error
401401
*/
402402
public byte[] getOdooSetupProtocolReport(int setupProtocolId) throws OpenemsNamedException {
403-
return OdooUtils.getOdooReport(this.credentials, "openems.report_openems_setup_protocol_template", setupProtocolId);
403+
return OdooUtils.getOdooReport(this.credentials, "openems.report_openems_setup_protocol_template",
404+
setupProtocolId);
404405
}
405406

406407
/**

io.openems.common/src/io/openems/common/utils/CollectorUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private CollectorUtils() {
4040
* {@link TreeBasedTable}.
4141
*
4242
* @param <KEY> the type of the first map key
43-
* @param <KEY2> the type of the second map key
43+
* @param <KEY2> the type of the second map key
4444
* @param <VALUE> the type of the value
4545
* @return the {@link Collector}
4646
*/

io.openems.common/src/io/openems/common/worker/AbstractWorker.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ public abstract class AbstractWorker {
3838
/**
3939
* Initializes the worker and starts the worker thread.
4040
*
41-
* @param name the name of the worker thread
42-
* @param initiallyTriggerNextRun true if the {@link AbstractWorker#forever()} method
43-
* should get called immediately; if not false
41+
* @param name the name of the worker thread
42+
* @param initiallyTriggerNextRun true if the {@link AbstractWorker#forever()}
43+
* method should get called immediately; if not
44+
* false
4445
*/
4546
public void activate(String name, boolean initiallyTriggerNextRun) {
4647
this.startWorker(name, initiallyTriggerNextRun);
@@ -58,9 +59,10 @@ public void activate(String name) {
5859
/**
5960
* Modifies the worker thread.
6061
*
61-
* @param name the name of the worker thread
62-
* @param initiallyTriggerNextRun true if the {@link AbstractWorker#forever()} method
63-
* should get called immediately; if not false
62+
* @param name the name of the worker thread
63+
* @param initiallyTriggerNextRun true if the {@link AbstractWorker#forever()}
64+
* method should get called immediately; if not
65+
* false
6466
*/
6567
public void modified(String name, boolean initiallyTriggerNextRun) {
6668
if (!this.thread.isAlive() && !this.thread.isInterrupted() && !this.isStopped.get()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
package io.openems.edge.battery.test;
2+
3+
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
4+
import io.openems.edge.battery.api.Battery;
5+
import io.openems.edge.common.startstop.StartStop;
6+
import io.openems.edge.common.startstop.StartStoppable;
7+
import io.openems.edge.common.test.AbstractDummyOpenemsComponent;
8+
import io.openems.edge.common.test.TestUtils;
9+
10+
public abstract class AbstractDummyBattery<SELF extends AbstractDummyBattery<?>>
11+
extends AbstractDummyOpenemsComponent<SELF> implements Battery, StartStoppable {
12+
13+
protected AbstractDummyBattery(String id, io.openems.edge.common.channel.ChannelId[] firstInitialChannelIds,
14+
io.openems.edge.common.channel.ChannelId[]... furtherInitialChannelIds) {
15+
super(id, firstInitialChannelIds, furtherInitialChannelIds);
16+
}
17+
18+
@Override
19+
public final void setStartStop(StartStop value) throws OpenemsNamedException {
20+
this.withStartStop(value);
21+
}
22+
23+
/**
24+
* Set {@link StartStoppable.ChannelId#START_STOP}.
25+
*
26+
* @param value the value
27+
* @return myself
28+
*/
29+
public final SELF withStartStop(StartStop value) {
30+
TestUtils.withValue(this, StartStoppable.ChannelId.START_STOP, value);
31+
return this.self();
32+
}
33+
34+
/**
35+
* Set {@link Battery.ChannelId#SOC}.
36+
*
37+
* @param value the value
38+
* @return myself
39+
*/
40+
public final SELF withSoc(int value) {
41+
TestUtils.withValue(this, Battery.ChannelId.SOC, value);
42+
return this.self();
43+
}
44+
45+
/**
46+
* Set {@link Battery.ChannelId#SOH}.
47+
*
48+
* @param value the value
49+
* @return myself
50+
*/
51+
public final SELF withSoh(int value) {
52+
TestUtils.withValue(this, Battery.ChannelId.SOH, value);
53+
return this.self();
54+
}
55+
56+
/**
57+
* Set {@link Battery.ChannelId#CAPACITY}.
58+
*
59+
* @param value the value
60+
* @return myself
61+
*/
62+
public final SELF withCapacity(int value) {
63+
TestUtils.withValue(this, Battery.ChannelId.CAPACITY, value);
64+
return this.self();
65+
}
66+
67+
/**
68+
* Set {@link Battery.ChannelId#VOLTAGE}.
69+
*
70+
* @param value the value
71+
* @return myself
72+
*/
73+
public final SELF withVoltage(int value) {
74+
TestUtils.withValue(this, Battery.ChannelId.VOLTAGE, value);
75+
return this.self();
76+
}
77+
78+
/**
79+
* Set {@link Battery.ChannelId#CURRENT}.
80+
*
81+
* @param value the value
82+
* @return myself
83+
*/
84+
public final SELF withCurrent(int value) {
85+
TestUtils.withValue(this, Battery.ChannelId.CURRENT, value);
86+
return this.self();
87+
}
88+
89+
/**
90+
* Set {@link Battery.ChannelId#DISCHARGE_MAX_CURRENT}.
91+
*
92+
* @param value the value
93+
* @return myself
94+
*/
95+
public final SELF withDischargeMaxCurrent(int value) {
96+
TestUtils.withValue(this, Battery.ChannelId.DISCHARGE_MAX_CURRENT, value);
97+
return this.self();
98+
}
99+
100+
/**
101+
* Set {@link Battery.ChannelId#CHARGE_MAX_CURRENT}.
102+
*
103+
* @param value the value
104+
* @return myself
105+
*/
106+
public final SELF withChargeMaxCurrent(int value) {
107+
TestUtils.withValue(this, Battery.ChannelId.CHARGE_MAX_CURRENT, value);
108+
return this.self();
109+
}
110+
111+
/**
112+
* Set {@link Battery.ChannelId#DISCHARGE_MIN_VOLTAGE}.
113+
*
114+
* @param value the value
115+
* @return myself
116+
*/
117+
public final SELF withDischargeMinVoltage(int value) {
118+
TestUtils.withValue(this, Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, value);
119+
return this.self();
120+
}
121+
122+
/**
123+
* Set {@link Battery.ChannelId#CHARGE_MAX_VOLTAGE}.
124+
*
125+
* @param value the value
126+
* @return myself
127+
*/
128+
public final SELF withChargeMaxVoltage(int value) {
129+
TestUtils.withValue(this, Battery.ChannelId.CHARGE_MAX_VOLTAGE, value);
130+
return this.self();
131+
}
132+
133+
/**
134+
* Set {@link Battery.ChannelId#MIN_CELL_VOLTAGE}.
135+
*
136+
* @param value the value
137+
* @return myself
138+
*/
139+
public final SELF withMinCellVoltage(int value) {
140+
TestUtils.withValue(this, Battery.ChannelId.MIN_CELL_VOLTAGE, value);
141+
return this.self();
142+
}
143+
144+
/**
145+
* Set {@link Battery.ChannelId#MAX_CELL_VOLTAGE}.
146+
*
147+
* @param value the value
148+
* @return myself
149+
*/
150+
public final SELF withMaxCellVoltage(int value) {
151+
TestUtils.withValue(this, Battery.ChannelId.MAX_CELL_VOLTAGE, value);
152+
return this.self();
153+
}
154+
155+
/**
156+
* Set {@link Battery.ChannelId#MIN_CELL_TEMPERATURE}.
157+
*
158+
* @param value the value
159+
* @return myself
160+
*/
161+
public final SELF withMinCellTemperature(int value) {
162+
TestUtils.withValue(this, Battery.ChannelId.MIN_CELL_TEMPERATURE, value);
163+
return this.self();
164+
}
165+
166+
/**
167+
* Set {@link Battery.ChannelId#MAX_CELL_TEMPERATURE}.
168+
*
169+
* @param value the value
170+
* @return myself
171+
*/
172+
public final SELF withMaxCellTemperature(int value) {
173+
TestUtils.withValue(this, Battery.ChannelId.MAX_CELL_TEMPERATURE, value);
174+
return this.self();
175+
}
176+
177+
}

0 commit comments

Comments
 (0)