Merge branch 'DEVELOP'
diff --git a/SARIS-Interface/pom.xml b/SARIS-Interface/pom.xml
index 6d05fa6..cc8a30c 100644
--- a/SARIS-Interface/pom.xml
+++ b/SARIS-Interface/pom.xml
@@ -57,6 +57,10 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
@@ -113,6 +117,15 @@
<version>4.2.1.RELEASE</version>
</dependency>
+ <!-- https://mvnrepository.com/artifact/org.springframework.ws/spring-ws-test -->
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-test</artifactId>
+ <version>3.0.10.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+
+
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
@@ -147,6 +160,12 @@
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-test</artifactId>
+ <version>5.3.2.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -214,8 +233,6 @@
<generatePackage>org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl</generatePackage>
<schemaIncludes>
<include>*.wsdl</include>
- <!-- <include>countries.wsdl</include> -->
- <!-- <include>Stoerungenservice.wsdl</include> -->
</schemaIncludes>
<catalog>${project.basedir}/src/main/resources/catalog.cat</catalog>
</configuration>
@@ -226,6 +243,39 @@
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ftp</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <scp todir="fdietrich@169.50.13.154:/opt/mics/sarisInterface/"
+ sftp="true" port="22" trust="true"
+ keyfile="${user.home}/.ssh/privateOpenKQServer.ppk"
+ failonerror="false" verbose="true" passphrase="">
+ <fileset dir="${project.build.directory}">
+ <include name="*.jar" />
+ </fileset>
+ </scp>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-jsch</artifactId>
+ <version>1.9.4</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
</plugins>
</build>
diff --git a/SARIS-Interface/sarisRealMockResponse.xml b/SARIS-Interface/sarisRealMockResponse.xml
new file mode 100644
index 0000000..973412b
--- /dev/null
+++ b/SARIS-Interface/sarisRealMockResponse.xml
@@ -0,0 +1,131 @@
+<GetAktuelleGVUsInfoAllgemeinResponse xmlns="http://tempuri.org/">
+ <GetAktuelleGVUsInfoAllgemeinResult>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95674</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T09:00:00</Beginn>
+ <Ende>2020-02-11T11:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Jesteburg</Ort>
+ <Ortsteil>Jesteburg </Ortsteil>
+ <Strasse>Kleckerwaldweg</Strasse>
+ <Hausnummern>56-58</Hausnummern>
+ <Bemerkung>ON Umschwenken in neue Trafostation
+ Kabelarbeiten</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>335587</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286047</Stoerung>
+ <Plz>21266</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95709</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T09:00:00</Beginn>
+ <Ende>2020-02-11T11:30:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Hollern-Twielenfleth</Ort>
+ <Strasse>Feriendorf Altes Land</Strasse>
+ <Hausnummern>75,77</Hausnummern>
+ <Bemerkung>Wasserschaden bei Hs.Nr.77
+ HAK von der Wand nehmen damit die Wand erneuert werden kann.</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>333815</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286453</Stoerung>
+ <Plz>21723</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95733</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T10:30:00</Beginn>
+ <Ende>2020-02-11T15:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Bülkau</Ort>
+ <Ortsteil>Bülkau </Ortsteil>
+ <Strasse>Süderende</Strasse>
+ <Hausnummern>29-48</Hausnummern>
+ <Bemerkung>Kabelstörung bei Hs. Nr.33</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>312795</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286625</Stoerung>
+ <Plz>21782</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95687</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T12:00:00</Beginn>
+ <Ende>2020-02-11T15:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Schwanewede</Ort>
+ <Ortsteil>Schwanewede </Ortsteil>
+ <Strasse>Lindenstr.</Strasse>
+ <Hausnummern>23-29</Hausnummern>
+ <Bemerkung>Austausch eines defekten Kabelverteilers (Beschädigung). </Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>362161</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286118</Stoerung>
+ <Plz>28790</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95647</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T13:00:00</Beginn>
+ <Ende>2020-02-11T14:30:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Dörpen</Ort>
+ <Ortsteil>Neudörpen </Ortsteil>
+ <Strasse>Neudörpen</Strasse>
+ <Hausnummern>14a; 15; 16; 17; 31; 34</Hausnummern>
+ <Bemerkung>KVS Wechsel bei Hs.Nr.: Neudörpen 15</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>317353</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>285933</Stoerung>
+ <Plz>26892</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95661</VersorgungsunterbrechungID>
+ <Beginn>2020-02-12T09:00:00</Beginn>
+ <Ende>2020-02-12T11:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Lathen</Ort>
+ <Ortsteil>Lathen </Ortsteil>
+ <Strasse>Zur Düne</Strasse>
+ <Hausnummern>10+15</Hausnummern>
+ <Bemerkung>KVS tausch</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>339961</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>285988</Stoerung>
+ <Plz>49762</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95743</VersorgungsunterbrechungID>
+ <Beginn>2020-02-12T10:00:00</Beginn>
+ <Ende>2020-02-12T12:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Grasberg</Ort>
+ <Ortsteil>Meinershausen </Ortsteil>
+ <Strasse>Meinershauser Str.</Strasse>
+ <Hausnummern>150-174</Hausnummern>
+ <Bemerkung/>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>327076</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286676</Stoerung>
+ <Plz>28879</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ </GetAktuelleGVUsInfoAllgemeinResult>
+</GetAktuelleGVUsInfoAllgemeinResponse>
diff --git a/SARIS-Interface/sonar-project.properties b/SARIS-Interface/sonar-project.properties
index 542718f..7e18aae 100644
--- a/SARIS-Interface/sonar-project.properties
+++ b/SARIS-Interface/sonar-project.properties
@@ -1,7 +1,7 @@
# must be unique in a given SonarQube instance
-sonar.projectKey=openk.pta.de:stoerungsauskunftinterface
+sonar.projectKey=openk.pta.de:sarisinterface
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
-sonar.projectName=grid-failure-information.stoerungsauskunftinterface
+sonar.projectName=grid-failure-information.sarisinterface
sonar.projectVersion=0.0.1_Snapshot
sonar.java.binaries=target/classes
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/api/StoerungsauskunftApi.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/api/StoerungsauskunftApi.java
deleted file mode 100644
index e5bccd0..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/api/StoerungsauskunftApi.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (c) 2019 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************
-*/
-package org.eclipse.openk.gridfailureinformation.sarisinterface.api;
-
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftOutage;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftUserNotification;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import java.util.List;
-
-
-@FeignClient(name="Stoerauskunft.de", url= "${stoerungsauskunft.apiUrl}")
-public interface StoerungsauskunftApi {
-
- @PostMapping(value= "/outage")
- feign.Response postOutage(@RequestBody List<StoerungsauskunftOutage> outage);
-
- @GetMapping(value= "/reports")
- List<StoerungsauskunftUserNotification> getUserNotification(@RequestParam(value="sectorType") Integer sectorType);
-
-}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/FeignClientConfig.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/FeignClientConfig.java
deleted file mode 100644
index c10a547..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/FeignClientConfig.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
-
-import feign.RequestInterceptor;
-import feign.auth.BasicAuthRequestInterceptor;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Log4j2
-@Configuration
-public class FeignClientConfig {
-
- @Value("${stoerungsauskunft.user}")
- public String user;
- @Value("${stoerungsauskunft.password}")
- public String password;
-
- @Bean
- public RequestInterceptor basicAuthRequestInterceptor() {
- return new BasicAuthRequestInterceptor(user, password);
- }
-
-}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfig.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfig.java
index a7f9df9..e744cf3 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfig.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfig.java
@@ -1,6 +1,7 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.ImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -13,15 +14,15 @@
@Log4j2
@Configuration
@EnableScheduling
-@ConditionalOnProperty(prefix = "stoerungsauskunft.scheduling-import", name = "enabled", havingValue = "true", matchIfMissing = false)
+@ConditionalOnProperty(prefix = "saris.scheduling-import", name = "enabled", havingValue = "true", matchIfMissing = false)
public class ImportSchedulerConfig {
- private static final String SCHEDULER_NAME = "Stoerauskunftimport-Scheduler";
+ private static final String SCHEDULER_NAME = "SARIS-Import-Scheduler";
@Autowired
ImportService importService;
- @Value("${stoerungsauskunft.scheduling-import.cron}")
+ @Value("${saris.scheduling-import.cron}")
private String cronExpression;
@Bean
@@ -29,10 +30,12 @@
log.info(SCHEDULER_NAME + " is enabled with cron expression: " + cronExpression);
}
- @Scheduled(cron = "${stoerungsauskunft.scheduling-import.cron}")
- public void scheduleTaskImportUserNotifications() {
- log.info("Executing" + SCHEDULER_NAME + " task: Importing available usernotifications from stoerungsauskunft.de");
- importService.importUserNotifications();
- log.info("Finished " + SCHEDULER_NAME + " task: Importing available usernotifications from stoerungsauskunft.de");
+ @Scheduled(cron = "${saris.scheduling-import.cron}")
+ public void scheduleTaskImportMessages() {
+ log.info("Executing" + SCHEDULER_NAME + " task: Importing available messages from SARIS");
+ importService.importForeignFailures(Constants.SARIS_ELECTRICITY_BRANCH_ID);
+ importService.importForeignFailures(Constants.SARIS_WATER_BRANCH_ID);
+ importService.importForeignFailures(Constants.SARIS_GAS_BRANCH_ID);
+ log.info("Finished " + SCHEDULER_NAME + " task: Importing available messages from SARIS");
}
}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SecurityConfig.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SecurityConfig.java
new file mode 100644
index 0000000..f1e9426
--- /dev/null
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SecurityConfig.java
@@ -0,0 +1,68 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.factory.PasswordEncoderFactories;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(
+ prePostEnabled = true,
+ securedEnabled = true,
+ jsr250Enabled = true)
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Value("${security.endpoint.user}")
+ private String user;
+ @Value("${security.endpoint.password}")
+ private String password;
+
+ @Override
+ protected void configure(HttpSecurity http ) throws Exception {
+ http
+ .csrf().disable()
+ .authorizeRequests().anyRequest().authenticated()
+ .and()
+ .httpBasic();
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return PasswordEncoderFactories.createDelegatingPasswordEncoder();
+ }
+
+ @Autowired
+ public void configureGlobal(AuthenticationManagerBuilder auth)
+ throws Exception
+ {
+ auth.inMemoryAuthentication()
+ .withUser(user)
+ .password(passwordEncoder().encode(password))
+ .roles("USER");
+ }
+
+
+}
+
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapClientConfig.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapClientConfig.java
deleted file mode 100644
index e9888d4..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapClientConfig.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
-/*
-import com.sun.xml.internal.ws.developer.JAXBContextFactory;
-import feign.codec.Decoder;
-import feign.codec.Encoder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class SoapClientConfig {
-
- private static final JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder()
- .withMarshallerJAXBEncoding("UTF-8")
- .withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
- .build();
-
- @Bean
- public Encoder feignEncoder() {
- return new SOAPEncoder(jaxbFactory);
- }
- @Bean
- public Decoder feignDecoder() {
- return new SOAPDecoder(jaxbFactory);
- }
-}*/
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapConfiguration.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapConfiguration.java
index bbb1d82..2c33b76 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapConfiguration.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/SoapConfiguration.java
@@ -2,6 +2,7 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.SarisWebservice;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
@@ -9,11 +10,13 @@
@Configuration
public class SoapConfiguration {
+ @Value("${saris.apiUrl}")
+ public String sarisApiUrl;
+
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
- // this package must match the package in the <generatePackage> specified in
- // pom.xml
+ // this package must match the package in the <generatePackage> specified in pom.xml
marshaller.setContextPath("org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl");
return marshaller;
}
@@ -21,7 +24,7 @@
@Bean
public SarisWebservice sarisWebservice(Jaxb2Marshaller marshaller) {
SarisWebservice sarisWebservice = new SarisWebservice();
-// sarisWebservice.setDefaultUri("http://localhost:8080/ws");
+ sarisWebservice.setDefaultUri(sarisApiUrl);
sarisWebservice.setMarshaller(marshaller);
sarisWebservice.setUnmarshaller(marshaller);
return sarisWebservice;
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/constants/Constants.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/constants/Constants.java
index 6af0a63..3ca592e 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/constants/Constants.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/constants/Constants.java
@@ -14,17 +14,27 @@
*/
package org.eclipse.openk.gridfailureinformation.sarisinterface.constants;
+import org.apache.tomcat.jni.OS;
+
public final class Constants {
public static final String SRC_SARIS = "SARIS";
+ public static final String BRANCH_WATER = "W";
+ public static final String BRANCH_GAS = "G";
public static final String BRANCH_ELECTRICITY = "S";
+ public static final String BRANCH_OTHER = "OS";
+
+ public static final int SARIS_GAS_BRANCH_ID = 2898;
+ public static final int SARIS_ELECTRICITY_BRANCH_ID = 2899;
+ public static final int SARIS_WATER_BRANCH_ID = 2900;
+
+
+
public static final String VOLTAGE_LVL_LOW = "NS";
public static final String PLANNED_OUTAGE = "planned";
public static final String UNPLANNED_OUTAGE = "unplanned";
- public static final String SRC_STOERUNGSAUSKUNFT_DE = "stoerungsauskunft.de";
-
private Constants() {
// empty Constructor for the sake of SONAR
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportController.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportController.java
index 985eaf2..02ab067 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportController.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportController.java
@@ -18,19 +18,17 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.ImportService;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.SarisWebservice;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemein;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ArrayOfViewGeplanteVU;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetCountryResponse;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ViewGeplanteVU;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.io.File;
+import java.util.List;
@Log4j2
@RestController
@@ -43,7 +41,7 @@
@Autowired
private SarisWebservice sarisWebservice;
- @GetMapping("/usernotification-import-test")
+ @GetMapping("/import-test")
@ApiOperation(value = "Import einer externen Störungsinformation von Störungsauskunft.de zu SIT")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Störungsinformation erfolgreich importiert"),
@@ -51,33 +49,29 @@
})
@ResponseStatus(HttpStatus.OK)
public void importUserNotification() {
- importService.importUserNotifications();
+ importService.importForeignFailures(Constants.SARIS_ELECTRICITY_BRANCH_ID);
+ importService.importForeignFailures(Constants.SARIS_GAS_BRANCH_ID);
+ importService.importForeignFailures(Constants.SARIS_WATER_BRANCH_ID);
}
- @GetMapping("/soap-test")
+ @GetMapping("/response-test")
@ApiOperation(value = "Import von Störungsinformationen von SARIS zu SIT")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Störungsinformation erfolgreich importiert"),
@ApiResponse(code = 500, message = "Konnte nicht durchgeführt werden")
})
@ResponseStatus(HttpStatus.OK)
- public void testSoap() throws JAXBException {
- GetCountryResponse response = sarisWebservice.getCountry("Spain");
- System.err.println(response.getCountry().getCurrency());
- }
-
- @GetMapping("/importForeignFailures-test")
- @ApiOperation(value = "Import von Störungsinformationen von SARIS zu SIT")
- @ApiResponses(value = {
- @ApiResponse(code = 201, message = "Störungsinformation erfolgreich importiert"),
- @ApiResponse(code = 500, message = "Konnte nicht durchgeführt werden")
- })
- @ResponseStatus(HttpStatus.OK)
- public void importForeignFailures() throws JAXBException {
-
- importService.importForeignFailures();
- GetCountryResponse response = sarisWebservice.getCountry("Spain");
- System.err.println(response.getCountry().getCurrency());
+ public void responsetest() {
+ log.info("response-test");
+ GetAktuelleGVUsInfoAllgemeinResponse response = sarisWebservice.getAktuelleGVU(Constants.SARIS_ELECTRICITY_BRANCH_ID,true);
+ log.info("RESPONSE received import-test: " + response);
+ ArrayOfViewGeplanteVU getAktuelleGVUsInfoAllgemeinResult = response.getGetAktuelleGVUsInfoAllgemeinResult();
+ if (getAktuelleGVUsInfoAllgemeinResult != null) {
+ List<ViewGeplanteVU> viewGeplanteVU = response.getGetAktuelleGVUsInfoAllgemeinResult().getViewGeplanteVU();
+ for (ViewGeplanteVU geplanteVU : viewGeplanteVU) {
+ log.info("VersorgungsunterbrechungID: " + geplanteVU.getVersorgungsunterbrechungID());
+ }
+ }
}
}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/ForeignFailureDataDto.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/ForeignFailureDataDto.java
index cf0bf46..4f4b79e 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/ForeignFailureDataDto.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/ForeignFailureDataDto.java
@@ -75,7 +75,7 @@
private String street;
@Size(max=10)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.;:-]+")
private String housenumber;
@Size(max=200)
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftOutage.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftOutage.java
deleted file mode 100644
index 2f4cf93..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftOutage.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.openk.gridfailureinformation.sarisinterface.dtos;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-@Data
-public class StoerungsauskunftOutage implements Serializable {
-
- private String id;
- private String operatorID;
- private String type;
- private Integer origin;
- private Integer geoType;
- private String date;
- private String estimatedEnding;
- private String postcode;
- private String city;
- private String district;
- private String ags;
- private Integer radius;
- private String coordinates;
- private String liveInfo;
- private Integer social;
- private String socialText;
-
-}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftUserNotification.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftUserNotification.java
deleted file mode 100644
index 196de63..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/dtos/StoerungsauskunftUserNotification.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.openk.gridfailureinformation.sarisinterface.dtos;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import lombok.Data;
-
-import java.io.Serializable;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Data
-public class StoerungsauskunftUserNotification implements Serializable {
-
- private String id;
- private String date;
- private String postcode;
- private String city;
- private String street;
- private String houseNo;
- private String district;
- private String ags;
- private String lat;
- private String lng;
- private String comment;
-
-}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/SARISMapper.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/SARISMapper.java
index 9f52736..00751e8 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/SARISMapper.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/SARISMapper.java
@@ -15,30 +15,18 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.mapper;
import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.FailureInformationDto;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureDataDto;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftOutage;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftUserNotification;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ViewGeplanteVU;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
-import org.mapstruct.Named;
import org.mapstruct.ReportingPolicy;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface SARISMapper {
- Pattern STREET_HOUSENUMBER_PATTERN = Pattern.compile("(^\\D+)(\\d.*)");
-
@Mappings({
@Mapping(target = "description", source = "bemerkung"),
@Mapping(target = "failureBegin", source = "beginn", dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"),
@@ -47,35 +35,29 @@
@Mapping(target = "city", source = "ort"),
@Mapping(target = "district", source = "ortsteil"),
@Mapping(target = "street", source = "strasse"),
- @Mapping(target = "housenumber", source = "hausnummern"), //TODO Mehrere Hausnummern möglich
- @Mapping(target = "branch", source = "sparte", qualifiedByName = "branchMapperToForeignFailureDataDto"),
+ @Mapping(target = "housenumber", source = "hausnummern")
})
ForeignFailureDataDto toForeignFailureDataDto(ViewGeplanteVU srcEntity);
@AfterMapping
default void afterMappingProcess(ViewGeplanteVU srcEntity, @MappingTarget ForeignFailureDataDto targetEntity){
+ if (targetEntity.getDistrict() != null) {
+ targetEntity.setDistrict(targetEntity.getDistrict().trim());
+ }
targetEntity.setRadiusInMeters(0L);
- targetEntity.setVoltageLevel(Constants.VOLTAGE_LVL_LOW); //TODO abhängig von Sparte, s. Sparte TODO
- }
-
- @Named("branchMapperToForeignFailureDataDto")
- default String branchMapperToForeignFailureDataDto(String sparteViewGeplanteVU) {
- if (sparteViewGeplanteVU == null || sparteViewGeplanteVU.isEmpty()) return "";
- //TODO logik implementieren. Was sind mögliche Sparten-Werte von SARIS?
- return sparteViewGeplanteVU;
- }
-
- @Named("housenumberMapperToForeignFailureDataDto")
- default String housenumberMapperToForeignFailureDataDto(String streetFromUserNotification) {
- if (streetFromUserNotification == null || streetFromUserNotification.isEmpty()) return "";
- String housenumber = "";
- Matcher matcher = STREET_HOUSENUMBER_PATTERN.matcher(streetFromUserNotification);
- if (matcher.matches()) {
- housenumber = matcher.group(2).trim();
+ targetEntity.setBranch(Constants.BRANCH_OTHER);
+ if (srcEntity.getSparteID() == 2899) {
+ targetEntity.setBranch(Constants.BRANCH_ELECTRICITY);
+ targetEntity.setVoltageLevel(Constants.VOLTAGE_LVL_LOW);
}
- return housenumber;
+ if (srcEntity.getSparteID() == 2900) {
+ targetEntity.setBranch(Constants.BRANCH_WATER);
+ }
+ if (srcEntity.getSparteID() == 2898) {
+ targetEntity.setBranch(Constants.BRANCH_GAS);
+ }
}
}
\ No newline at end of file
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/StoerungsauskunftMapper.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/StoerungsauskunftMapper.java
deleted file mode 100644
index 24bf71d..0000000
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/mapper/StoerungsauskunftMapper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (c) 2019 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************
- */
-package org.eclipse.openk.gridfailureinformation.sarisinterface.mapper;
-
-import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.FailureInformationDto;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureDataDto;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftOutage;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftUserNotification;
-import org.mapstruct.*;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
-public interface StoerungsauskunftMapper {
-
- final Pattern STREET_HOUSENUMBER_PATTERN = Pattern.compile("(^\\D+)(\\d.*)");
-
- @Mappings({
- @Mapping(target = "description", source = "comment"),
- @Mapping(target = "failureBegin", source = "date", dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"),
- @Mapping(target = "longitude", source = "lng"),
- @Mapping(target = "latitude", source = "lat"),
- @Mapping(target = "street", source = "street", qualifiedByName = "streetMapperToForeignFailureDataDto"),
- @Mapping(target = "housenumber", source = "houseNo"),
- })
- ForeignFailureDataDto toForeignFailureDataDto(StoerungsauskunftUserNotification srcEntity);
-
-
- @AfterMapping
- default void afterMappingProcess(StoerungsauskunftUserNotification srcEntity, @MappingTarget ForeignFailureDataDto targetEntity){
- if (targetEntity.getHousenumber() == null || targetEntity.getHousenumber().isEmpty()){
- targetEntity.setHousenumber(housenumberMapperToForeignFailureDataDto(srcEntity.getStreet()));
- }
- targetEntity.setRadiusInMeters(0L);
- targetEntity.setVoltageLevel(Constants.VOLTAGE_LVL_LOW);
- }
-
- @Named("streetMapperToForeignFailureDataDto")
- default String streetMapperToForeignFailureDataDto(String streetFromUserNotification) {
- if (streetFromUserNotification == null || streetFromUserNotification.isEmpty()) return "";
- String street = streetFromUserNotification;
- Matcher matcher = STREET_HOUSENUMBER_PATTERN.matcher(streetFromUserNotification);
- if (matcher.matches()) {
- street = matcher.group(1).trim();
- }
- return street;
- }
-
- @Named("housenumberMapperToForeignFailureDataDto")
- default String housenumberMapperToForeignFailureDataDto(String streetFromUserNotification) {
- if (streetFromUserNotification == null || streetFromUserNotification.isEmpty()) return "";
- String housenumber = "";
- Matcher matcher = STREET_HOUSENUMBER_PATTERN.matcher(streetFromUserNotification);
- if (matcher.matches()) {
- housenumber = matcher.group(2).trim();
- }
- return housenumber;
- }
-
- /* Exportmapper */
-
- @AfterMapping
- default void setCoordinates(@MappingTarget StoerungsauskunftOutage target, FailureInformationDto srcEntity) {
-
- //Störungsauskunft.de Koordinatenformat: LNG,LAT;LNG,LAT; …
-
- List<ArrayList<BigDecimal>> addressPolygonPoints = srcEntity.getAddressPolygonPoints();
- if (addressPolygonPoints != null && !addressPolygonPoints.isEmpty()) {
- String coordinatesResult = "";
- for (ArrayList<BigDecimal> addressPolygonPoint : addressPolygonPoints) {
- //index 0: = Lat / index 1:= Lng
- coordinatesResult = coordinatesResult.concat(addressPolygonPoint.get(1).toString() + "," + addressPolygonPoint.get(0).toString() +";");
- }
- target.setCoordinates(coordinatesResult);
- } else {
- target.setCoordinates(srcEntity.getLongitude()+ "," + srcEntity.getLatitude());
- }
-
- }
-
- @Mappings({
- @Mapping(target = "liveInfo", source = "description"),
- @Mapping(target = "date", source = "failureBegin", dateFormat = "dd.MM.yyyy HH:mm:ss"),
- @Mapping(target = "estimatedEnding", source = "failureEndPlanned", dateFormat = "dd.MM.yyyy HH:mm:ss"),
- })
- StoerungsauskunftOutage toStoerungsauskunftOutage(FailureInformationDto srcEntity);
-
-
-
-}
\ No newline at end of file
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportService.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportService.java
index ab83b58..7b28384 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportService.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportService.java
@@ -18,12 +18,9 @@
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureDataDto;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureMessageDto;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.api.StoerungsauskunftApi;
import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.StoerungsauskunftUserNotification;
import org.eclipse.openk.gridfailureinformation.sarisinterface.exceptions.InternalServerErrorException;
import org.eclipse.openk.gridfailureinformation.sarisinterface.mapper.SARISMapper;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.mapper.StoerungsauskunftMapper;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ArrayOfViewGeplanteVU;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ViewGeplanteVU;
@@ -39,6 +36,7 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
@Service
@@ -48,18 +46,12 @@
public class ImportService {
@Autowired
- private StoerungsauskunftApi stoerungsauskunftApi;
-
- @Autowired
private MessageChannel failureImportChannel;
@Autowired
private ObjectMapper objectMapper;
@Autowired
- StoerungsauskunftMapper stoerungsauskunftMapper;
-
- @Autowired
SARISMapper sarisMapper;
@Autowired
@@ -68,40 +60,39 @@
@Value("${gridFailureInformation.autopublish:false}")
private boolean autopublish;
- public void importForeignFailures() throws JAXBException {
+ public void importForeignFailures(int sarisSparteId) {
-// GetAktuelleGVUsInfoAllgemeinResponse sarisResponse = sarisWebservice.getAktuelleGVU();
+// GetAktuelleGVUsInfoAllgemeinResponse sarisResponse = sarisWebservice.getAktuelleGVU(sarisSparteId, false);
- GetAktuelleGVUsInfoAllgemeinResponse sarisResponse = getMockedSarisResponse();
+ GetAktuelleGVUsInfoAllgemeinResponse sarisResponse = getMockedSarisResponse("sarisRealMockResponse.xml");
ArrayOfViewGeplanteVU getAktuelleGVUsInfoAllgemeinResult = sarisResponse.getGetAktuelleGVUsInfoAllgemeinResult();
if (getAktuelleGVUsInfoAllgemeinResult != null) {
List<ViewGeplanteVU> viewGeplanteVU = sarisResponse.getGetAktuelleGVUsInfoAllgemeinResult().getViewGeplanteVU();
+ List<ForeignFailureMessageDto> messageDtoList = new ArrayList<>();
for (ViewGeplanteVU geplanteVU : viewGeplanteVU) {
pushForeignFailure(createForeignFailureMessageDto(geplanteVU));
ForeignFailureMessageDto foreignFailureMessageDto = createForeignFailureMessageDto(geplanteVU);
- log.info("VersorgungsunterbrechungID: " + geplanteVU.getVersorgungsunterbrechungID());
+ messageDtoList.add(foreignFailureMessageDto);
+ log.info("foreignFailureMessageDto.getMetaId() " + foreignFailureMessageDto.getMetaId());
}
+ log.debug(messageDtoList);
}
}
- private GetAktuelleGVUsInfoAllgemeinResponse getMockedSarisResponse() throws JAXBException {
- JAXBContext jaxbContext = JAXBContext.newInstance(GetAktuelleGVUsInfoAllgemeinResponse.class);
- Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ private GetAktuelleGVUsInfoAllgemeinResponse getMockedSarisResponse(String xmlResponseFile) {
+ GetAktuelleGVUsInfoAllgemeinResponse response = null;
+ try {
+ JAXBContext jaxbContext = JAXBContext.newInstance(GetAktuelleGVUsInfoAllgemeinResponse.class);
+ Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ File file = new File(xmlResponseFile);
+ response = (GetAktuelleGVUsInfoAllgemeinResponse) jaxbUnmarshaller.unmarshal(file);
- File file = new File("sarisMockResponse.xml");
- return (GetAktuelleGVUsInfoAllgemeinResponse) jaxbUnmarshaller.unmarshal(file);
- }
-
- public void importUserNotifications() {
-
-// List<StoerungsauskunftUserNotification> userNotificationList =
-// stoerungsauskunftApi.getUserNotification(1);
-//
-// for (StoerungsauskunftUserNotification userNotification : userNotificationList) {
-// pushForeignFailure(createForeignFailureMessageDto(userNotification));
-// }
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ return response;
}
private ForeignFailureMessageDto createForeignFailureMessageDto(ViewGeplanteVU viewGeplanteVU) {
@@ -115,7 +106,6 @@
private ForeignFailureDataDto createForeignFailureData(ViewGeplanteVU viewGeplanteVU) {
ForeignFailureDataDto foreignFailureDataDto = sarisMapper.toForeignFailureDataDto(viewGeplanteVU);
- foreignFailureDataDto.setBranch(Constants.BRANCH_ELECTRICITY);
foreignFailureDataDto.setPlanned(true);
foreignFailureDataDto.setAutopublish(autopublish);
return foreignFailureDataDto;
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebservice.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebservice.java
index 6799b72..62a5a1b 100644
--- a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebservice.java
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebservice.java
@@ -2,56 +2,74 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.service;
+import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemein;
import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetCountryRequest;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetCountryResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
+import org.springframework.ws.soap.client.core.SoapActionCallback;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.io.File;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.GregorianCalendar;
+@Log4j2
public class SarisWebservice extends WebServiceGatewaySupport {
- private static final Logger log = LoggerFactory.getLogger(SarisWebservice.class);
+ @Value("${saris.apiUrl}")
+ public String sarisApiUrl;
- public GetCountryResponse getCountry(String country) {
+ @Value("${saris.user}")
+ public String sarisUser;
+ @Value("${saris.password}")
+ public String sarisPassword;
- GetCountryRequest request = new GetCountryRequest();
- request.setName(country);
+ @Value("${saris.bisToleranz}")
+ public int sarisBisToleranz;
+ @Value("${saris.vonToleranz}")
+ public int sarisVonToleranz;
- log.info("Requesting location for " + country);
+ @Value("${saris.testIntegration.year}")
+ public int testYearIntegration;
+ @Value("${saris.testIntegration.month}")
+ public int testMonthIntegration;
+ @Value("${saris.testIntegration.day}")
+ public int testDayIntegration;
- /*GetCountryResponse response = (GetCountryResponse) getWebServiceTemplate()
- .marshalSendAndReceive("http://localhost:8080/ws/countries", request,
- new SoapActionCallback(
- "http://spring.io/guides/gs-producing-web-service/GetCountryRequest"));*/
-
- GetCountryResponse response = (GetCountryResponse) getWebServiceTemplate()
- .marshalSendAndReceive("http://localhost:8080/ws/countries", request);
-
- return response;
- }
-
- public GetAktuelleGVUsInfoAllgemeinResponse getAktuelleGVU() {
+ public GetAktuelleGVUsInfoAllgemeinResponse getAktuelleGVU(int sarisSparteId, boolean testCall) {
log.info("getAktuelleGVU called");
+ LocalDate localDate = LocalDate.now(ZoneId.of("Europe/Berlin"));
+ if (testCall) localDate = LocalDate.of(testYearIntegration, testMonthIntegration, testDayIntegration);
+
+ GregorianCalendar gcal = GregorianCalendar.from(localDate.atStartOfDay(ZoneId.of("Europe/Berlin")));
+ XMLGregorianCalendar xcal = null;
+ try {
+ xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
+ } catch (DatatypeConfigurationException e) {
+ log.error("Error while trying to convert to newXMLGregorianCalendar", e);
+ }
GetAktuelleGVUsInfoAllgemein request = new GetAktuelleGVUsInfoAllgemein();
+ request.setBisToleranz(sarisBisToleranz);
+ request.setVonToleranz(sarisVonToleranz);
+ request.setSparteId(sarisSparteId);
+ request.setDienstplanId(0);
+ request.setDateTime(xcal);
- GetAktuelleGVUsInfoAllgemeinResponse response = (GetAktuelleGVUsInfoAllgemeinResponse) getWebServiceTemplate()
- .marshalSendAndReceive("http://sariskon/sariskon/services/Stoerungenservice.asmx", request);
+ WebServiceTemplate webServiceTemplate = getWebServiceTemplate();
+ webServiceTemplate.setCheckConnectionForFault(true);
+ webServiceTemplate.setCheckConnectionForError(true);
+ webServiceTemplate.setMessageSender(new WebServiceMessageSenderWithAuth(sarisUser, sarisPassword));
-/* GetAktuelleGVUsInfoAllgemeinResponse response = (GetAktuelleGVUsInfoAllgemeinResponse) getWebServiceTemplate()
- .marshalSendAndReceive("http://sariskon/sariskon/services/Stoerungenservice.asmx", request, new SoapActionCallback(
- "http://tempuri.org/GetAktuelleGVUsInfoAllgemein"));*/
+ GetAktuelleGVUsInfoAllgemeinResponse response = (GetAktuelleGVUsInfoAllgemeinResponse) webServiceTemplate
+ .marshalSendAndReceive(sarisApiUrl, request, new SoapActionCallback(
+ "http://tempuri.org/GetAktuelleGVUsInfoAllgemein"));
return response;
}
-
-
}
diff --git a/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/WebServiceMessageSenderWithAuth.java b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/WebServiceMessageSenderWithAuth.java
new file mode 100644
index 0000000..c0e5ac4
--- /dev/null
+++ b/SARIS-Interface/src/main/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/WebServiceMessageSenderWithAuth.java
@@ -0,0 +1,37 @@
+package org.eclipse.openk.gridfailureinformation.sarisinterface.service;
+
+import lombok.extern.log4j.Log4j2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Service;
+import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.Base64;
+
+@Log4j2
+public class WebServiceMessageSenderWithAuth extends HttpUrlConnectionMessageSender {
+
+
+ private final String user;
+ private final String password;
+
+ public WebServiceMessageSenderWithAuth(String user, String password) {
+ this.user = user;
+ this.password = password;
+ }
+
+ @Override
+ protected void prepareConnection(HttpURLConnection connection)
+ throws IOException {
+ Base64.Encoder enc = Base64.getEncoder();
+ String userpassword = user +":"+ password;
+ String encodedAuthorization = enc.encodeToString(userpassword.getBytes());
+ connection.setRequestProperty("Authorization", "Basic " + encodedAuthorization);
+
+ super.prepareConnection(connection);
+ }
+}
diff --git a/SARIS-Interface/src/main/resources/application.yml b/SARIS-Interface/src/main/resources/application.yml
index aedb437..a3eef9e 100644
--- a/SARIS-Interface/src/main/resources/application.yml
+++ b/SARIS-Interface/src/main/resources/application.yml
@@ -29,6 +29,7 @@
org.springframework.web: ERROR
server:
+ port: 9196
max-http-header-size: 262144
feign:
@@ -38,29 +39,45 @@
connectTimeout: 60000
readTimeout: 60000
-stoerungsauskunft:
- apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
- user: ${GFI_STOERUNGSAUSKUNFT_USERNAME}
- password: ${GFI_STOERUNGSAUSKUNFT_PASSWORD}
+saris:
+ apiUrl: https://twh.ewe.de/sariskon/sariskon/services/Stoerungenservice.asmx
+ user: ${GFI_SARIS_USERNAME}
+ password: ${GFI_SARIS_PASSWORD}
+ bisToleranz: 1440
+ vonToleranz: 1440
scheduling-import:
enabled: false
cron: 0 */15 * ? * *
+ testIntegration:
+ day: 11
+ month: 2
+ year: 2020
+
+
gridFailureInformation:
autopublish: false
+security.endpoint:
+ user: ${GFI_MANUAL_ENDPOINTS_USERNAME}
+ password: ${GFI_MANUAL_ENDPOINTS_PASSWORD}
+
---
spring:
profiles: test
-stoerungsauskunft:
- apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+saris:
+ apiUrl: https://apiTestUrl
user: userName
password: secPwd
scheduling-import:
enabled: true
cron: 0 */15 * ? * *
+
+security.endpoint:
+ user: userName
+ password: secPwd
---
spring:
@@ -118,14 +135,15 @@
level:
root: INFO
org.eclipse.openk: DEBUG
- org.springframework.web: ERROR
+ org.springframework.web: TRACE
+ org.springframework.ws: TRACE
server:
- port: 9195
+ port: 9196
max-http-header-size: 262144
servlet:
session:
tracking-modes: cookie
swagger:
- baseUrl: /test-stoerungsauskunft-interface
\ No newline at end of file
+ baseUrl: /test-saris-interface
\ No newline at end of file
diff --git a/SARIS-Interface/src/main/resources/application_localdev.yml b/SARIS-Interface/src/main/resources/application_localdev.yml
index 6c42049..221bef8 100644
--- a/SARIS-Interface/src/main/resources/application_localdev.yml
+++ b/SARIS-Interface/src/main/resources/application_localdev.yml
@@ -46,19 +46,22 @@
readTimeout: 5000
loggerLevel: FULL
-logging.level.org.eclipse.openk.gridfailureinformation.jobs.stoerauskunftinterface.api.StoerauskunftApi: DEBUG
-
-stoerungsauskunft:
- apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
- user: ${GFI_STOERUNGSAUSKUNFT_USERNAME}
- password: ${GFI_STOERUNGSAUSKUNFT_PASSWORD}
+saris:
+ apiUrl: https://twh.ewe.de/sariskon/sariskon/services/Stoerungenservice.asmx
+ user: ${GFI_SARIS_USERNAME}
+ password: ${GFI_SARIS_PASSWORD}
+ bisToleranz: 1440
+ vonToleranz: 1440
scheduling-import:
enabled: false
cron: 0 */15 * ? * *
-
+
gridFailureInformation:
autopublish: false
+security.endpoint:
+ user: ${GFI_MANUAL_ENDPOINTS_USERNAME}
+ password: ${GFI_MANUAL_ENDPOINTS_PASSWORD}
---
spring:
diff --git a/SARIS-Interface/src/main/resources/logback-spring.xml b/SARIS-Interface/src/main/resources/logback-spring.xml
index c7cacfb..c4132d4 100644
--- a/SARIS-Interface/src/main/resources/logback-spring.xml
+++ b/SARIS-Interface/src/main/resources/logback-spring.xml
@@ -6,7 +6,7 @@
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
- %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%c{60}): %msg%n%throwable
+ %d{ISO8601} %highlight(%-5level) [%blue(%t)] %yellow(%c{60}): %msg%n%throwable
</Pattern>
</layout>
</appender>
@@ -24,19 +24,6 @@
</rollingPolicy>
</appender>
- <appender name="RollingFileFeign" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${LOGS}/feignclient.log</file>
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <Pattern>%d %p %c{60} [%t] %m%n</Pattern>
- </encoder>
-
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${LOGS}/archived/feignclient-%d{yyyy-MM-dd}.gz</fileNamePattern>
- <MaxHistory>30</MaxHistory>
- <cleanHistoryOnStart>true</cleanHistoryOnStart>
- </rollingPolicy>
- </appender>
-
<!-- LOG everything at INFO level -->
<root level="info">
<appender-ref ref="RollingFileStd"/>
@@ -49,8 +36,4 @@
<appender-ref ref="Console"/>
</logger>
- <logger name="org.eclipse.openk.gridfailureinformation.sarisinterface.api.StoerungsauskunftApi" level="info" additivity="false">
- <appender-ref ref="RollingFileFeign"/>
- </logger>
-
</configuration>
\ No newline at end of file
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfigTest.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfigTest.java
index 74bc188..61393fa 100644
--- a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfigTest.java
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/ImportSchedulerConfigTest.java
@@ -1,8 +1,10 @@
package org.eclipse.openk.gridfailureinformation.sarisinterface.config;
import org.eclipse.openk.gridfailureinformation.sarisinterface.SarisInterfaceApplication;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.api.StoerungsauskunftApi;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.ImportService;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.service.SarisWebservice;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.support.MockDataHelper;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -10,26 +12,36 @@
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@SpringBootTest(classes = SarisInterfaceApplication.class)
@ContextConfiguration(classes = {TestConfiguration.class})
@ActiveProfiles("test")
public class ImportSchedulerConfigTest {
+ @MockBean
+ private SarisWebservice sarisWebservice;
+
@SpyBean
private ImportService importService;
- @MockBean
- private StoerungsauskunftApi stoerungsauskunftApi;
-
@Autowired
private ImportSchedulerConfig importSchedulerConfig;
@Test
public void shoulImportUserNotification() {
- importSchedulerConfig.scheduleTaskImportUserNotifications();
- verify(importService, times(1)).importUserNotifications();
+
+ GetAktuelleGVUsInfoAllgemeinResponse mockedSarisResponse = MockDataHelper.getMockedSarisResponse(
+ "sarisRealMockResponse.xml");
+
+ when(sarisWebservice.getAktuelleGVU(anyInt(), anyBoolean())).thenReturn(mockedSarisResponse);
+
+ importSchedulerConfig.scheduleTaskImportMessages();
+ verify(importService, times(3)).importForeignFailures(anyInt());
}
}
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/TestConfiguration.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/TestConfiguration.java
index 7ad433f..68162c0 100644
--- a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/TestConfiguration.java
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/config/TestConfiguration.java
@@ -19,7 +19,7 @@
import com.rabbitmq.client.Channel;
import org.eclipse.openk.gridfailureinformation.sarisinterface.SarisInterfaceApplication;
import org.eclipse.openk.gridfailureinformation.sarisinterface.config.rabbitMq.RabbitMqConfig;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.mapper.StoerungsauskunftMapperImpl;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.mapper.SARISMapperImpl;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.connection.Connection;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
@@ -29,6 +29,7 @@
import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.MessageChannel;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
@@ -50,7 +51,7 @@
ObjectMapper objectMapper() { return new ObjectMapper(); }
@Bean
- public StoerungsauskunftMapperImpl stoerungsauskunftMapper() {return new StoerungsauskunftMapperImpl();}
+ public SARISMapperImpl sarisMapper() {return new SARISMapperImpl();}
@Bean
public MessageChannel failureImportChannel() {return mock(MessageChannel.class);}
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportControllerTest.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportControllerTest.java
index f34c4e6..375b766 100644
--- a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportControllerTest.java
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/controller/ImportControllerTest.java
@@ -14,17 +14,22 @@
*/
package org.eclipse.openk.gridfailureinformation.sarisinterface.controller;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.openk.gridfailureinformation.sarisinterface.SarisInterfaceApplication;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.api.StoerungsauskunftApi;
import org.eclipse.openk.gridfailureinformation.sarisinterface.service.ImportService;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.service.SarisWebservice;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.support.MockDataHelper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -37,7 +42,7 @@
public class ImportControllerTest {
@MockBean
- private StoerungsauskunftApi stoerungsauskunftApi;
+ private SarisWebservice sarisWebservice;
@MockBean
private ImportService importService;
@@ -47,11 +52,21 @@
@Test
+ @WithMockUser(value = "mockedUser")
public void shouldCallImport() throws Exception {
- mockMvc.perform(get("/stoerungsauskunft/usernotification-import-test"))
+ mockMvc.perform(get("/saris/import-test"))
.andExpect(status().is2xxSuccessful());
- verify(importService, times(1)).importUserNotifications();
+ verify(importService, times(3)).importForeignFailures(anyInt());
+ }
+
+ @Test
+ public void shouldCallImportAndReturnUnauthorized() throws Exception {
+
+ mockMvc.perform(get("/saris/import-test"))
+ .andExpect(status().isUnauthorized());
+
+ verify(importService, times(0)).importForeignFailures(anyInt());
}
}
\ No newline at end of file
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportServiceTest.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportServiceTest.java
index fc8f6ce..6ea27f6 100644
--- a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportServiceTest.java
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/ImportServiceTest.java
@@ -16,16 +16,25 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.openk.gridfailureinformation.sarisinterface.SarisInterfaceApplication;
-import org.eclipse.openk.gridfailureinformation.sarisinterface.api.StoerungsauskunftApi;
import org.eclipse.openk.gridfailureinformation.sarisinterface.config.TestConfiguration;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureMessageDto;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.support.MockDataHelper;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
+import java.io.IOException;
+import java.io.InputStream;
+
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
@SpringBootTest(classes = SarisInterfaceApplication.class)
@ContextConfiguration(classes = {TestConfiguration.class})
@@ -35,43 +44,25 @@
@Autowired
private ImportService importService;
- @Autowired
- ObjectMapper objectMapper;
-
@MockBean
- StoerungsauskunftApi stoerungsauskunftApi;
-
- /* @Test
- public void shoulImportUserNotification() throws IOException {
-
- ImportService importExportServicSpy = spy(importService);
-
- InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream();
- List<StoerungsauskunftUserNotification> userNotificationList =
- objectMapper.readValue(is, new TypeReference<List<StoerungsauskunftUserNotification>>() {
- });
- when(stoerungsauskunftApi.getUserNotification(any(Integer.class))).thenReturn(userNotificationList);
-
- importExportServicSpy.importUserNotifications();
-
- verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class));
- }
+ SarisWebservice sarisWebservice;
@Test
- public void shoulImportUserNotificationMapperTest1() throws IOException {
+ public void shoulImportUserNotification() {
- ImportService importExportServicSpy = spy(importService);
+ ImportService importServiceSpy = spy(this.importService);
- InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream();
- List<StoerungsauskunftUserNotification> userNotificationList =
- objectMapper.readValue(is, new TypeReference<List<StoerungsauskunftUserNotification>>() {
- });
- when(stoerungsauskunftApi.getUserNotification(any(Integer.class))).thenReturn(userNotificationList);
+ GetAktuelleGVUsInfoAllgemeinResponse mockedSarisResponse = MockDataHelper.getMockedSarisResponse(
+ "sarisRealMockResponse.xml");
- importExportServicSpy.importUserNotifications();
+ when(sarisWebservice.getAktuelleGVU(anyInt(), anyBoolean())).thenReturn(mockedSarisResponse);
- verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class));
- }*/
+ int mockedSarisResponseListSize = mockedSarisResponse.getGetAktuelleGVUsInfoAllgemeinResult().getViewGeplanteVU().size();
+
+ importServiceSpy.importForeignFailures(Constants.SARIS_ELECTRICITY_BRANCH_ID);
+
+ verify(importServiceSpy, times(mockedSarisResponseListSize)).pushForeignFailure(any(ForeignFailureMessageDto.class));
+ }
}
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebServiceTest.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebServiceTest.java
new file mode 100644
index 0000000..06994cc
--- /dev/null
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/service/SarisWebServiceTest.java
@@ -0,0 +1,88 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.gridfailureinformation.sarisinterface.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.SarisInterfaceApplication;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.config.TestConfiguration;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.constants.Constants;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.support.MockDataHelper;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.util.ResourceLoaderBase;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.ViewGeplanteVU;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.ws.client.core.WebServiceMessageCallback;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import org.springframework.ws.test.client.MockWebServiceServer;
+import org.springframework.ws.test.client.RequestMatchers;
+import org.springframework.xml.transform.StringSource;
+
+import javax.xml.transform.Source;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.springframework.ws.test.client.RequestMatchers.payload;
+import static org.springframework.ws.test.client.ResponseCreators.withPayload;
+
+@SpringBootTest(classes = SarisInterfaceApplication.class)
+@ContextConfiguration(classes = {TestConfiguration.class})
+@ActiveProfiles("test")
+public class SarisWebServiceTest {
+
+ @MockBean
+ WebServiceTemplate webServiceTemplate;
+
+ @Autowired
+ private SarisWebservice sarisWebservice;
+
+ @Test
+ public void shouldGetAktuelleGVU() throws IOException {
+
+ SarisWebservice sarisWebservice = spy(this.sarisWebservice);
+
+ GetAktuelleGVUsInfoAllgemeinResponse mockedSarisResponse = MockDataHelper.getMockedSarisResponse(
+ "sarisRealMockResponse.xml");
+
+ when(webServiceTemplate.marshalSendAndReceive(anyString(), any(), any())).thenReturn(mockedSarisResponse);
+ when(sarisWebservice.getWebServiceTemplate()).thenReturn(webServiceTemplate);
+
+ GetAktuelleGVUsInfoAllgemeinResponse aktuelleGVU =
+ sarisWebservice.getAktuelleGVU(Constants.SARIS_ELECTRICITY_BRANCH_ID, false);
+
+ assertFalse(aktuelleGVU.getGetAktuelleGVUsInfoAllgemeinResult().getViewGeplanteVU().isEmpty());
+ assertEquals(mockedSarisResponse, aktuelleGVU);
+
+ }
+
+
+}
diff --git a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/support/MockDataHelper.java b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/support/MockDataHelper.java
index 6f82c6b..3c3acce 100644
--- a/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/support/MockDataHelper.java
+++ b/SARIS-Interface/src/test/java/org/eclipse/openk/gridfailureinformation/sarisinterface/support/MockDataHelper.java
@@ -18,7 +18,12 @@
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.FailureInformationDto;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureDataDto;
import org.eclipse.openk.gridfailureinformation.sarisinterface.dtos.ForeignFailureMessageDto;
+import org.eclipse.openk.gridfailureinformation.sarisinterface.wsdl.GetAktuelleGVUsInfoAllgemeinResponse;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.File;
import java.math.BigDecimal;
import java.sql.Date;
import java.text.ParseException;
@@ -37,7 +42,7 @@
public static ForeignFailureMessageDto mockForeignFailureDto() throws ParseException {
ForeignFailureMessageDto foreignFailureMessageDto = new ForeignFailureMessageDto();
foreignFailureMessageDto.setMetaId("a4509482-3be2-4402-a9bd-ff91649b9c1e");
- foreignFailureMessageDto.setSource(Constants.SRC_STOERUNGSAUSKUNFT_DE);
+ foreignFailureMessageDto.setSource(Constants.SRC_SARIS);
foreignFailureMessageDto.setDescription("Rohrbruch");
ForeignFailureDataDto dataDto = new ForeignFailureDataDto();
@@ -55,7 +60,7 @@
public static ForeignFailureMessageDto mockForeignFailureDtoWithCoordinates() throws ParseException {
ForeignFailureMessageDto foreignFailureMessageDto = new ForeignFailureMessageDto();
foreignFailureMessageDto.setMetaId("a4509482-3be2-4402-a9bd-ff91649b9c1e");
- foreignFailureMessageDto.setSource(Constants.SRC_STOERUNGSAUSKUNFT_DE);
+ foreignFailureMessageDto.setSource(Constants.SRC_SARIS);
foreignFailureMessageDto.setDescription("Rohrbruch");
ForeignFailureDataDto dataDto = new ForeignFailureDataDto();
@@ -159,4 +164,18 @@
return cordinatesList;
}
+ public static GetAktuelleGVUsInfoAllgemeinResponse getMockedSarisResponse(String xmlResponseFile) {
+ GetAktuelleGVUsInfoAllgemeinResponse response = null;
+ try {
+ JAXBContext jaxbContext = JAXBContext.newInstance(GetAktuelleGVUsInfoAllgemeinResponse.class);
+ Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ File file = new File(xmlResponseFile);
+ response = (GetAktuelleGVUsInfoAllgemeinResponse) jaxbUnmarshaller.unmarshal(file);
+
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+
}
diff --git a/SARIS-Interface/src/test/resources/UsernotificationJsonResponse.json b/SARIS-Interface/src/test/resources/UsernotificationJsonResponse.json
deleted file mode 100644
index fb469bf..0000000
--- a/SARIS-Interface/src/test/resources/UsernotificationJsonResponse.json
+++ /dev/null
@@ -1,69 +0,0 @@
-[
- {
- "id": 24,
- "date": "28.5.2020 14:49:11",
- "postcode": "55237",
- "city": "Bornheim",
- "ags": null,
- "district": null,
- "street": "Bahnhofstraße 27",
- "lat": "49.8031615",
- "lng": "8.1932478",
- "comment": "Licht aus",
- "operatorOutageInArea": 0
- },
- {
- "id": 23,
- "date": "28.5.2020 14:49:11",
- "postcode": "55237",
- "city": "Flonheim",
- "ags": null,
- "district": null,
- "street": "Am Obertor",
- "lat": "49.8031615",
- "lng": "8.1932478",
- "comment": "Zappenduster",
- "operatorOutageInArea": 0,
- "houseNo": "13"
- },
- {
- "id": 23,
- "date": "28.5.2020 14:49:11",
- "postcode": "55237",
- "city": "Flonheim",
- "ags": null,
- "district": null,
- "lat": "49.8031615",
- "lng": "8.1932478",
- "comment": "Zappenduster",
- "operatorOutageInArea": 0
- },
- {
- "id": 23,
- "date": "28.5.2020 14:49:11",
- "postcode": "55237",
- "city": "Flonheim",
- "ags": null,
- "street": "",
- "district": null,
- "lat": "49.8031615",
- "lng": "8.1932478",
- "comment": "Zappenduster",
- "operatorOutageInArea": 0,
- "houseNo": ""
- },
- {
- "id": 23,
- "date": "28.5.2020 14:49:11",
- "postcode": "55237",
- "city": "Flonheim",
- "ags": null,
- "district": null,
- "street": "Am Obertor",
- "lat": "49.8031615",
- "lng": "8.1932478",
- "comment": "Zappenduster",
- "phone": "01520123456",
- "operatorOutageInArea": 0
- }
-]
\ No newline at end of file
diff --git a/SARIS-Interface/src/test/resources/application.yml b/SARIS-Interface/src/test/resources/application.yml
index 843be83..654aaeb 100644
--- a/SARIS-Interface/src/test/resources/application.yml
+++ b/SARIS-Interface/src/test/resources/application.yml
@@ -31,15 +31,6 @@
server:
max-http-header-size: 262144
-jwt:
- tokenHeader: Authorization
- useStaticJwt: false
- staticJwt: x
-
-gridFailureInformation:
- maxListSize: 2000
-
-
feign:
client:
config:
@@ -49,26 +40,34 @@
cors:
corsEnabled: false
-stoerungsauskunft:
- apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+saris:
+ apiUrl: https://apiTestUrl/api/v1.0/
user: userName
password: secPwd
+ bisToleranz: 1440
+ vonToleranz: 1440
scheduling-import:
enabled: false
cron: 0 */15 * ? * *
+ testIntegration:
+ year: 2020
+ month: 2
+ day: 11
+
+gridFailureInformation:
+ autopublish: false
+
+security.endpoint:
+ user: userName
+ password: secPwd
---
spring:
profiles: test
-jwt:
- tokenHeader: Authorization
- useStaticJwt: true
- staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZTlhMjQ2Njg1YTU0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjJmMWIzODE5LWZjNjQtNDEzNC1iNWQxLWY3ZWY4NzU5NDBkNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFkbWluIiwia29uLXdyaXRlciIsImtvbi1hY2Nlc3MiLCJrb24tcmVhZGVyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSBUZXN0ZXJMYXN0bmFtZV9yd2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0dXNlcl9yd2EiLCJnaXZlbl9uYW1lIjoiVGVzdGVyRmlyc3RuYW1lX3J3YSIsImZhbWlseV9uYW1lIjoiVGVzdGVyTGFzdG5hbWVfcndhIn0.DAYXuv4tKn8RXqO1jyttnD-tF4nShUBQyfe4bKbAiPAyY2x5YbAf3M4eXnLrGqo8-loGKldICC28bL0LaMA3KKkQEOfW5sfpGqoN6212vs89mOklt0TJYc5PMXwFgJ5WC_TKjdwq7-aaDafOEWehV0U1ut3s-94ovNYIEn29nzXm2W1ldoXJEq03F880jlysQ5zlRvGF7eXEEpFfI2URyyNQ2UWh0Ssfq-gOAt2pbF1u6prA5RfvUmZ3v1eu21YLGZtgqPqxb1l6odyH3ip15j_HdgnTeo52ymxuRUj65Mskme3V5ev2DitHI9vZgnpV8Idhb4TTWliBeGCOMfDFCg
-
-stoerungsauskunft:
- apiUrl: https://stage-api-operator.stoerungsauskunft.de/api/v1.0/
+saris:
+ apiUrl: https://apiTestUrl
user: userName
password: secPwd
scheduling-import:
diff --git a/SARIS-Interface/src/test/resources/sarisRealMockResponse.xml b/SARIS-Interface/src/test/resources/sarisRealMockResponse.xml
new file mode 100644
index 0000000..973412b
--- /dev/null
+++ b/SARIS-Interface/src/test/resources/sarisRealMockResponse.xml
@@ -0,0 +1,131 @@
+<GetAktuelleGVUsInfoAllgemeinResponse xmlns="http://tempuri.org/">
+ <GetAktuelleGVUsInfoAllgemeinResult>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95674</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T09:00:00</Beginn>
+ <Ende>2020-02-11T11:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Jesteburg</Ort>
+ <Ortsteil>Jesteburg </Ortsteil>
+ <Strasse>Kleckerwaldweg</Strasse>
+ <Hausnummern>56-58</Hausnummern>
+ <Bemerkung>ON Umschwenken in neue Trafostation
+ Kabelarbeiten</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>335587</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286047</Stoerung>
+ <Plz>21266</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95709</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T09:00:00</Beginn>
+ <Ende>2020-02-11T11:30:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Hollern-Twielenfleth</Ort>
+ <Strasse>Feriendorf Altes Land</Strasse>
+ <Hausnummern>75,77</Hausnummern>
+ <Bemerkung>Wasserschaden bei Hs.Nr.77
+ HAK von der Wand nehmen damit die Wand erneuert werden kann.</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>333815</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286453</Stoerung>
+ <Plz>21723</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95733</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T10:30:00</Beginn>
+ <Ende>2020-02-11T15:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Bülkau</Ort>
+ <Ortsteil>Bülkau </Ortsteil>
+ <Strasse>Süderende</Strasse>
+ <Hausnummern>29-48</Hausnummern>
+ <Bemerkung>Kabelstörung bei Hs. Nr.33</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>312795</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286625</Stoerung>
+ <Plz>21782</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95687</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T12:00:00</Beginn>
+ <Ende>2020-02-11T15:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Schwanewede</Ort>
+ <Ortsteil>Schwanewede </Ortsteil>
+ <Strasse>Lindenstr.</Strasse>
+ <Hausnummern>23-29</Hausnummern>
+ <Bemerkung>Austausch eines defekten Kabelverteilers (Beschädigung). </Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>362161</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286118</Stoerung>
+ <Plz>28790</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95647</VersorgungsunterbrechungID>
+ <Beginn>2020-02-11T13:00:00</Beginn>
+ <Ende>2020-02-11T14:30:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Dörpen</Ort>
+ <Ortsteil>Neudörpen </Ortsteil>
+ <Strasse>Neudörpen</Strasse>
+ <Hausnummern>14a; 15; 16; 17; 31; 34</Hausnummern>
+ <Bemerkung>KVS Wechsel bei Hs.Nr.: Neudörpen 15</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>317353</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>285933</Stoerung>
+ <Plz>26892</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95661</VersorgungsunterbrechungID>
+ <Beginn>2020-02-12T09:00:00</Beginn>
+ <Ende>2020-02-12T11:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Lathen</Ort>
+ <Ortsteil>Lathen </Ortsteil>
+ <Strasse>Zur Düne</Strasse>
+ <Hausnummern>10+15</Hausnummern>
+ <Bemerkung>KVS tausch</Bemerkung>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>339961</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>285988</Stoerung>
+ <Plz>49762</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ <ViewGeplanteVU>
+ <VersorgungsunterbrechungID>95743</VersorgungsunterbrechungID>
+ <Beginn>2020-02-12T10:00:00</Beginn>
+ <Ende>2020-02-12T12:00:00</Ende>
+ <AnzahlKunden>0</AnzahlKunden>
+ <Ort>Grasberg</Ort>
+ <Ortsteil>Meinershausen </Ortsteil>
+ <Strasse>Meinershauser Str.</Strasse>
+ <Hausnummern>150-174</Hausnummern>
+ <Bemerkung/>
+ <Realisiert>false</Realisiert>
+ <StrassenAbschnittID>327076</StrassenAbschnittID>
+ <LetzteAenderungAm>0001-01-01T00:00:00</LetzteAenderungAm>
+ <Stoerung>286676</Stoerung>
+ <Plz>28879</Plz>
+ <SparteID>2899</SparteID>
+ <Sparte>GVU Strom</Sparte>
+ </ViewGeplanteVU>
+ </GetAktuelleGVUsInfoAllgemeinResult>
+</GetAktuelleGVUsInfoAllgemeinResponse>
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
index 1c4bfed..0416414 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java
@@ -37,6 +37,8 @@
import org.eclipse.openk.gridfailureinformation.repository.DistributionGroupRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationPublicationChannelRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
+import org.eclipse.openk.gridfailureinformation.util.ExternalStatusCalculator;
import org.eclipse.openk.gridfailureinformation.util.GroupMemberPlzFilter;
import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupMemberDto;
import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionTextPlaceholderDto;
@@ -98,6 +100,9 @@
private FailureInformationRepository failureInformationRepository;
@Autowired
+ private StatusRepository statusRepository;
+
+ @Autowired
private FailureInformationPublicationChannelRepository publicationChannelRepository;
@Autowired
@@ -425,6 +430,11 @@
contentReplaceMap.put(placeholderDto.getStatusIntern(), statusIntern.getStatus());
}
+ String statusExtern = getStatusExtern(tblFailureInfo);
+ if (statusExtern != null) {
+ contentReplaceMap.put(placeholderDto.getStatusExtern(), statusExtern);
+ }
+
String publicationStatus = tblFailureInfo.getPublicationStatus();
if (publicationStatus != null) {
contentReplaceMap.put(placeholderDto.getPublicationStatus(), publicationStatus);
@@ -516,11 +526,17 @@
}
+ private String getStatusExtern(TblFailureInformation tblFailureInfo) {
+ FailureInformationDto failureInformationDto = failureInformationMapper.toFailureInformationDto(tblFailureInfo);
+ return ExternalStatusCalculator.addExternalStatus(statusRepository, failureInformationDto);
+ }
+
private void initContentReplaceMap(DistributionTextPlaceholderDto placeholderDto) {
contentReplaceMap.put(placeholderDto.getFailureClassification(), "");
contentReplaceMap.put(placeholderDto.getInternalRemark(), "");
contentReplaceMap.put(placeholderDto.getResponsibility(), "");
contentReplaceMap.put(placeholderDto.getStatusIntern(), "");
+ contentReplaceMap.put(placeholderDto.getStatusExtern(), "");
contentReplaceMap.put(placeholderDto.getPublicationStatus(), "");
contentReplaceMap.put(placeholderDto.getBranch(), "");
contentReplaceMap.put(placeholderDto.getVoltageLevel(), "");
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportService.java
index 071c51f..98cfb1e 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportService.java
@@ -112,7 +112,7 @@
if (foreignFailureDataDto.isAutopublish()) {
failureInformationService.insertPublicationChannelForFailureInfo(retVal.getUuid(), Constants.PUBLICATION_CHANNEL_OWNDMZ, true);
log.info("External failure information [MetaId: " + importDataDto.getMetaId() + "] from "
- + importDataDto.getSource() + "is prepared for autopublish to channel: " + Constants.PUBLICATION_CHANNEL_OWNDMZ);
+ + importDataDto.getSource() + " is prepared for autopublish to channel: " + Constants.PUBLICATION_CHANNEL_OWNDMZ);
}
return retVal;
} else {
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/util/ExternalStatusCalculator.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/util/ExternalStatusCalculator.java
index b43403a..27ca03c 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/util/ExternalStatusCalculator.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/util/ExternalStatusCalculator.java
@@ -29,7 +29,7 @@
public class ExternalStatusCalculator {
private ExternalStatusCalculator() {}
- public static void addExternalStatus(StatusRepository statusRepository, FailureInformationDto failureInformationDto){
+ public static String addExternalStatus(StatusRepository statusRepository, FailureInformationDto failureInformationDto){
Long statusInternId = statusRepository.findByUuid(
failureInformationDto.getStatusInternId())
.orElseThrow(() -> new NotFoundException("status.not.found"))
@@ -49,10 +49,10 @@
ldtFailureEndPlanned = LocalDateTime.ofInstant(failureEndPlanned.toInstant(), ZoneId.systemDefault());
}
- failureInformationDto.setStatusExtern(
- ExternalStatusCalculator.calculate(
- statusInternId, publicationStatus, ldtFailureBegin,
- ldtFailureEndPlanned));
+ String statusExtern = ExternalStatusCalculator.calculate(statusInternId, publicationStatus, ldtFailureBegin,
+ ldtFailureEndPlanned);
+ failureInformationDto.setStatusExtern(statusExtern);
+ return statusExtern;
}
public static String calculate(Long statusInternId, String publicationStatus, LocalDateTime ldtFailureBegin, LocalDateTime ldtFailureEndPlanned) {
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/ForeignFailureDataDto.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/ForeignFailureDataDto.java
index 536fce6..a1846d3 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/ForeignFailureDataDto.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/viewmodel/ForeignFailureDataDto.java
@@ -64,19 +64,19 @@
private String postcode;
@Size(max=200)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.+-]+")
private String city;
@Size(max=200)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.+-]+")
private String district;
@Size(max=200)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()-]+")
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()&,.+-]+")
private String street;
- @Size(max=10)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.;:-]+")
+ @Size(max=200)
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/()&,.;:+-]+")
private String housenumber;
@Size(max=200)
@@ -84,7 +84,7 @@
private String stationId;
@Size(max=200)
- @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.;:-]+")
+ @Pattern(regexp="^$|[A-Za-z0-9ÄäÖöÜüß\\s_/(),.;:+-]+")
private String stationDescription;
private BigDecimal longitude;
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlacehoderServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlacehoderServiceTest.java
index ad83170..e90e9f0 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlacehoderServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlacehoderServiceTest.java
@@ -42,6 +42,7 @@
assertEquals("$Spannungsebene$", placeholderDto.getVoltageLevel());
assertEquals("$Störungsbeginn_gemeldet$", placeholderDto.getFailureBegin());
assertEquals("$Voraussichtlicher_Grund$", placeholderDto.getExpectedReason());
+ assertEquals("$Status_extern$", placeholderDto.getStatusExtern());
}
}
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
index bbd6986..8371712 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ExportServiceTest.java
@@ -21,13 +21,16 @@
import org.eclipse.openk.gridfailureinformation.config.rabbitMq.RabbitMqProperties;
import org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException;
import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapper;
+import org.eclipse.openk.gridfailureinformation.model.RefStatus;
import org.eclipse.openk.gridfailureinformation.model.TblDistributionGroup;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformationPublicationChannel;
import org.eclipse.openk.gridfailureinformation.repository.DistributionGroupRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationPublicationChannelRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
+import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
+import org.eclipse.openk.gridfailureinformation.util.ExternalStatusCalculator;
import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupMemberDto;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
import org.junit.jupiter.api.Test;
@@ -71,10 +74,13 @@
private DistributionGroupRepository distributionGroupRepository;
@MockBean
- private MessageChannel mailExportChannel;
+ private StatusRepository statusRepository;
@MockBean
- private FailureInformationMapper failureInformationMapper;
+ private MessageChannel mailExportChannel;
+
+ /*@MockBean
+ private FailureInformationMapper failureInformationMapper;*/
@MockBean
RabbitTemplate rabbitTemplate;
@@ -170,6 +176,8 @@
List<DistributionGroupMemberDto> listTblDistributionGroupMemberDtos = MockDataHelper.mockDistributionGroupMemberDtoList();
+ RefStatus refStatus = MockDataHelper.mockRefStatusQUALIFIED();
+ when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
when (failureInformationRepository.findByUuid( any(UUID.class))).thenReturn(Optional.of(tblFailureInformation));
when(distributionGroupMemberService.getMembersByGroupId(any(UUID.class))).thenReturn(listTblDistributionGroupMemberDtos);
when(distributionGroupRepository.findByFailureInformationId(anyLong())).thenReturn(listTblDistributionGroups);
@@ -207,7 +215,8 @@
List<TblDistributionGroup> listTblDistributionGroups= MockDataHelper.mockDistributionGroupList();
when(distributionGroupRepository.findByFailureInformationId(anyLong())).thenReturn(listTblDistributionGroups);
List<DistributionGroupMemberDto> listTblDistributionGroupMemberDtos = MockDataHelper.mockDistributionGroupMemberDtoList();
-
+ RefStatus refStatus = MockDataHelper.mockRefStatusQUALIFIED();
+ when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
when (failureInformationRepository.findByUuid( any(UUID.class))).thenReturn(Optional.of(tblFailureInformation));
when(distributionGroupMemberService.getMembersByGroupId(any(UUID.class))).thenReturn(listTblDistributionGroupMemberDtos);
when(publicationChannelRepository.save(any(TblFailureInformationPublicationChannel.class))).thenReturn(new TblFailureInformationPublicationChannel());
@@ -246,6 +255,8 @@
tblFailureInformation.setPostcode("112233");
tblFailureInformation.setHousenumber("10-1");
+ RefStatus refStatus = MockDataHelper.mockRefStatusQUALIFIED();
+ when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
List<TblDistributionGroup> listTblDistributionGroups= MockDataHelper.mockDistributionGroupList();
when(distributionGroupRepository.findByFailureInformationId(anyLong())).thenReturn(listTblDistributionGroups);
List<DistributionGroupMemberDto> listTblDistributionGroupMemberDtos = MockDataHelper.mockDistributionGroupMemberDtoList();
@@ -384,6 +395,8 @@
RabbitMqChannel rabbitMqChannel = MockDataHelper.mockRabbitMqChannelMail();
+ RefStatus refStatus = MockDataHelper.mockRefStatusQUALIFIED();
+ when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
when (failureInformationRepository.findByUuid( any(UUID.class))).thenReturn(Optional.of(tblFailureInformation));
when(distributionGroupRepository.findByName(any(String.class))).thenReturn(Optional.of(tblDistributionGroup));
when(distributionGroupMemberService.getMembersByGroupId(any(UUID.class))).thenReturn(listTblDistributionGroupMemberDtos);
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ImportServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ImportServiceTest.java
index aab6a28..28a6709 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ImportServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/ImportServiceTest.java
@@ -15,6 +15,7 @@
package org.eclipse.openk.gridfailureinformation.service;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
+import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.ProcessHelper;
import org.eclipse.openk.gridfailureinformation.config.TestConfiguration;
import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException;
import org.eclipse.openk.gridfailureinformation.support.MockDataHelper;
@@ -27,6 +28,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.ContextConfiguration;
import java.math.BigDecimal;
@@ -61,6 +63,9 @@
@MockBean
private FailureInformationService failureInformationService;
+ @MockBean
+ private ProcessHelper processHelper;
+
@Test
public void shouldImportDifferentRadiiProperly() throws Exception {
List<RadiusDto> radiusDtos = getRadiusDtoList();
@@ -314,7 +319,6 @@
" \"radiusInMeters\": 678,\n" +
" \"stationDescription\": null,\n" +
" \"stationId\": null,\n" +
- " \"street\": \"Oxfordstreet\",\n" +
" \"voltageLevel\": \"HS\"\n" +
" }");
@@ -434,4 +438,90 @@
.updateFailureInfo(any( FailureInformationDto.class));
}
+ @Test
+ public void shouldImportMessagesCorrectlyWithNewAutopublish() {
+ ImportDataDto dto = MockDataHelper.mockImportDataDto();
+ dto.setMessageContent("{\n" +
+ " \"branch\": \"S\",\n" + // invalid branch
+ " \"city\": \"Belfast\",\n" +
+ " \"description\": \"Schlimmer Fehler im System\",\n" +
+ " \"district\": \"\",\n" +
+ " \"failureBegin\": \"2020-11-19T14:13:15.666Z\",\n" +
+ " \"housenumber\": \"10b\",\n" +
+ " \"latitude\": 12.345,\n" +
+ " \"longitude\": 0,\n" +
+ " \"planned\": false,\n" +
+ " \"postcode\": \"3456\",\n" +
+ " \"pressureLevel\": null,\n" +
+ " \"radiusInMeters\": 678,\n" +
+ " \"stationDescription\": null,\n" +
+ " \"stationId\": null,\n" +
+ " \"street\": \"Oxfordstreet\",\n" +
+ " \"voltageLevel\": \"HS\",\n" +
+ " \"autopublish\": \"true\"\n" +
+ " }");
+
+ BranchDto branchStromDto = MockDataHelper.mockBranchDto();
+ branchStromDto.setName("S");
+ when( branchService.findByName(eq("S"))).thenReturn(branchStromDto);
+
+ FailureInformationDto savedFailureInformationDto = MockDataHelper.mockFailureInformationDto();
+ when( radiusService.getRadii() ).thenReturn(getRadiusDtoList());
+ when( failureInformationService.insertFailureInfo(any(), any())).thenReturn(savedFailureInformationDto);
+ //when( failureInformationService.insertPublicationChannelForFailureInfo(any(), anyString(), anyBoolean())).thenReturn(new FailureInformationPublicationChannelDto());
+
+ importService.validateAndImport(dto);
+
+ verify(failureInformationService, times(1))
+ .insertFailureInfo(any( FailureInformationDto.class), eq(GfiProcessState.QUALIFIED));
+ }
+
+ @Test
+ public void shouldImportUpdateMessageAutopublish() {
+ ImportDataDto dto = MockDataHelper.mockImportDataDto();
+ dto.setMessageContent("{\n" +
+ " \"branch\": \"S\",\n" + // invalid branch
+ " \"city\": \"Belfast\",\n" +
+ " \"description\": \"Schlimmer Fehler im System\",\n" +
+ " \"district\": \"\",\n" +
+ " \"failureBegin\": \"2020-11-19T14:13:15.666Z\",\n" +
+ " \"housenumber\": \"10b\",\n" +
+ " \"latitude\": 12.345,\n" +
+ " \"longitude\": 0,\n" +
+ " \"planned\": false,\n" +
+ " \"postcode\": \"3456\",\n" +
+ " \"pressureLevel\": null,\n" +
+ " \"radiusInMeters\": 678,\n" +
+ " \"stationDescription\": null,\n" +
+ " \"stationId\": null,\n" +
+ " \"street\": \"Oxfordstreet\",\n" +
+ " \"voltageLevel\": \"HS\",\n" +
+ " \"autopublish\": \"true\"\n" +
+ " }");
+
+ BranchDto branchStromDto = MockDataHelper.mockBranchDto();
+ branchStromDto.setName("S");
+ when( branchService.findByName(eq("S"))).thenReturn(branchStromDto);
+ StatusDto qualifiedStatusDto = MockDataHelper.mockStatusDto("qualified", UUID.randomUUID());
+ StatusDto canceledStatusDto = MockDataHelper.mockStatusDto("canceled", UUID.randomUUID());
+ StatusDto completedStatusDto = MockDataHelper.mockStatusDto("completed", UUID.randomUUID());
+ StatusDto udpatedStatusDto = MockDataHelper.mockStatusDto("updated", UUID.randomUUID());
+
+ when( statusService.getStatusFromId( GfiProcessState.QUALIFIED.getStatusValue()) ).thenReturn(qualifiedStatusDto);
+ when( statusService.getStatusFromId( GfiProcessState.COMPLETED.getStatusValue()) ).thenReturn(completedStatusDto);
+ when( statusService.getStatusFromId( GfiProcessState.CANCELED.getStatusValue()) ).thenReturn(canceledStatusDto);
+ when( statusService.getStatusFromId( GfiProcessState.UPDATED.getStatusValue()) ).thenReturn(udpatedStatusDto);
+ when( radiusService.getRadii() ).thenReturn(getRadiusDtoList());
+
+ FailureInformationDto existingDto = MockDataHelper.mockFailureInformationDto();
+ existingDto.setStatusInternId(qualifiedStatusDto.getUuid());
+ when( failureInformationService.findByObjectReferenceExternalSystem(anyString())).thenReturn(existingDto);
+
+ importService.validateAndImport(dto);
+
+ verify(failureInformationService, times(1))
+ .updateFailureInfo(any( FailureInformationDto.class));
+ verify(processHelper, times(1)).resetPublishedStateForChannels(any());
+ }
+
}