Skip to content

Commit

Permalink
JUnit test framework for OpenEMS Backend (#1884)
Browse files Browse the repository at this point in the history
Move AbstractComponentConfig from `io.openems.edge.common` to `io.openems.common`. This is the first step to use the existing JUnit test framework also for OpenEMS Backend.
  • Loading branch information
sfeilmeier committed Jul 7, 2022
1 parent 19c4e40 commit 2d6bd15
Show file tree
Hide file tree
Showing 117 changed files with 237 additions and 112 deletions.
@@ -0,0 +1,117 @@
package io.openems.backend.timedata.timescaledb;

import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {

protected static class Builder {
private String id = null;
public String host;
public int port;
public String user;
public String password;
public String database;
public boolean isReadOnly;
public WriteConfig betaWriteConfig;

private Builder() {
}

public Builder setId(String id) {
this.id = id;
return this;
}

public Builder setHost(String host) {
this.host = host;
return this;
}

public Builder setPort(int port) {
this.port = port;
return this;
}

public Builder setUser(String user) {
this.user = user;
return this;
}

public Builder setPassword(String password) {
this.password = password;
return this;
}

public Builder setDatabase(String database) {
this.database = database;
return this;
}

public Builder setReadOnly(boolean isReadOnly) {
this.isReadOnly = isReadOnly;
return this;
}

public Builder setBetaWriteConfig(WriteConfig betaWriteConfig) {
this.betaWriteConfig = betaWriteConfig;
return this;
}

public MyConfig build() {
return new MyConfig(this);
}
}

/**
* Create a Config builder.
*
* @return a {@link Builder}
*/
public static Builder create() {
return new Builder();
}

private final Builder builder;

private MyConfig(Builder builder) {
super(Config.class, builder.id);
this.builder = builder;
}

@Override
public String host() {
return this.builder.host;
}

@Override
public int port() {
return this.builder.port;
}

@Override
public String user() {
return this.builder.user;
}

@Override
public String password() {
return this.builder.password;
}

@Override
public String database() {
return this.builder.database;
}

@Override
public boolean isReadOnly() {
return this.builder.isReadOnly;
}

@Override
public WriteConfig betaWriteConfig() {
return this.builder.betaWriteConfig;
}

}
@@ -1,4 +1,4 @@
package io.openems.edge.common.test;
package io.openems.common.test;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
Expand Down
@@ -0,0 +1,3 @@
@org.osgi.annotation.versioning.Version("1.0.0")
@org.osgi.annotation.bundle.Export
package io.openems.common.test;
@@ -1,8 +1,8 @@
package io.openems.edge.battery.bmw;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.battery.bmw.enums.BatteryState;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.battery.bydcommercial;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.battery.fenecon.commercial;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.battery.fenecon.home;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,9 +1,9 @@
package io.openems.edge.battery.soltaro.cluster.versionb;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.battery.soltaro.common.enums.BatteryState;
import io.openems.edge.battery.soltaro.common.enums.ModuleType;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.battery.soltaro.cluster.versionc;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.battery.soltaro.single.versiona;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.battery.soltaro.common.enums.BatteryState;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,9 +1,9 @@
package io.openems.edge.battery.soltaro.single.versionb;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.battery.soltaro.common.enums.ModuleType;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,9 +1,9 @@
package io.openems.edge.battery.soltaro.single.versionc;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.battery.soltaro.common.enums.ModuleType;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.batteryinverter.kaco.blueplanetgridsave;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.batteryinverter.refu88k;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,10 +1,10 @@
package io.openems.edge.batteryinverter.sinexcel;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.batteryinverter.sinexcel.enums.CountryCode;
import io.openems.edge.batteryinverter.sinexcel.enums.EnableDisable;
import io.openems.edge.common.startstop.StartStopConfig;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,6 +1,6 @@
package io.openems.edge.bosch.bpts5hybrid.core;

import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,7 +1,7 @@
package io.openems.edge.bosch.bpts5hybrid.ess;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,7 +1,7 @@
package io.openems.edge.bosch.bpts5hybrid.meter;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,7 +1,7 @@
package io.openems.edge.bosch.bpts5hybrid.pv;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,9 +1,9 @@
package io.openems.edge.bridge.modbus;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.edge.bridge.modbus.api.LogVerbosity;
import io.openems.edge.bridge.modbus.api.Parity;
import io.openems.edge.bridge.modbus.api.Stopbit;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfigSerial extends AbstractComponentConfig implements ConfigSerial {
Expand Down
@@ -1,7 +1,7 @@
package io.openems.edge.bridge.modbus;

import io.openems.common.test.AbstractComponentConfig;
import io.openems.edge.bridge.modbus.api.LogVerbosity;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfigTcp extends AbstractComponentConfig implements ConfigTcp {
Expand Down
Expand Up @@ -26,6 +26,7 @@
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.exceptions.OpenemsException;
import io.openems.common.function.ThrowingRunnable;
import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.types.ChannelAddress;
import io.openems.common.types.OpenemsType;
import io.openems.edge.common.channel.Channel;
Expand Down
Expand Up @@ -10,6 +10,8 @@
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.ComponentInstance;

import io.openems.common.test.AbstractComponentConfig;

/**
* Simulates a {@link ComponentContext} for the OpenEMS Component test
* framework.
Expand Down
Expand Up @@ -14,6 +14,8 @@
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;

import io.openems.common.test.AbstractComponentConfig;

/**
* Simulates a ConfigurationAdmin for the OpenEMS Component test framework.
*/
Expand Down
Expand Up @@ -3,7 +3,7 @@
import java.net.Proxy.Type;

import io.openems.common.channel.PersistencePriority;
import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,7 +1,7 @@
package io.openems.edge.controller.api.mqtt;

import io.openems.common.channel.PersistencePriority;
import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,6 +1,6 @@
package io.openems.edge.controller.api.rest.readwrite;

import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,6 +1,6 @@
package io.openems.edge.controller.asymmetric.peakshaving;

import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,6 +1,6 @@
package io.openems.edge.controller.chp.soc;

import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,6 +1,6 @@
package io.openems.edge.controller.debuglog;

import io.openems.edge.common.test.AbstractComponentConfig;
import io.openems.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down
@@ -1,8 +1,8 @@
package io.openems.edge.controller.ess.activepowervoltagecharacteristic;

import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.test.AbstractComponentConfig;
import io.openems.common.utils.ConfigUtils;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {
Expand Down

0 comments on commit 2d6bd15

Please sign in to comment.