Skip to content

Commit

Permalink
Merge pull request #7 from axonivy-market/srf-weather-connector-mock
Browse files Browse the repository at this point in the history
XIVY-12055 Moved Mock-API to demo-project and updated Readme
  • Loading branch information
ivy-edp authored Sep 4, 2023
2 parents c06f2af + 38432bf commit f7253d1
Show file tree
Hide file tree
Showing 40 changed files with 104 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
push:
pull_request:
schedule:
- cron: '21 21 * * *'
- cron: "21 21 * * *"
workflow_dispatch:

jobs:
build:
uses: axonivy-market/github-workflows/.github/workflows/ci.yml@v2
with:
mvnArgs: -Dmaven.test.failure.ignore=true
mvnArgs: -Dmaven.test.failure.ignore=true -Divy.engine.version=10.0.11
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<module>${project.name}-demo</module>
<module>${project.name}-test</module>
<module>${project.name}-product</module>
<module>${project.name}-webTest</module>
</modules>

<scm>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.connector.srf.weather.connector.demo.Data
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.connector.srf.weather.connector.demo
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=111000
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
3 changes: 3 additions & 0 deletions srf-weather-connector-demo/config/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
Variables:
# All variables related to the SRF Weather connector
SrfWeatherConnector:
# For testing you can use the following Variable to refer to the testing Mock API under: 'http://localhost:8081/designer/api/weatherMock'
# Url: http://localhost:8081/designer/api/weatherMock

# Your Access Token for SRF weather connector
# This token serves as your authentication key for accessing the SRF API.
# [password]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@Path(WeatherMock.PATH_SUFFIX)
@PermitAll
public class WeatherMock {

static final String PATH_SUFFIX = "weatherMock";
// URI where this mock can be reached: to be referenced in tests that use it!
public static final String URI = "{ivy.app.baseurl}/api/" + PATH_SUFFIX;
Expand Down
9 changes: 6 additions & 3 deletions srf-weather-connector-product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ The connector:
* supports you with an easy-to-copy demo implementation to reduce your
integration effort.
* enables low code citizen developers to enhance existing business processes
with currency converter features.
with weather forecast features.

## Demo

Install the SRF Weather Connector and call it as a sub-process. Adjust the mapping accordingly.
![set connector as subprocess](images/demo1.png)

For testing purposes, a mock API can be used in the demo instead of the official SRF API. For this purpose, the variable "Url" can be commented out under 'Variables.SrfWeatherConnector'.
This way you can avoid the need to generate an access token via the SRF Developer website first. In this mock mode, only the ZIP code "6300" must be entered in the "zip" field.

In the demo, you can now specify either the name of the location or its ZIP code and use the "Get Weather" button to output the weather for the next seven days at this location.
![enter data name or zip](images/demo2.png)

Expand All @@ -28,12 +31,12 @@ The use of the SRF Weather API is not free of charge. For development purposes t
To use the connector, you must select a suitable API package via the [SRF API Developer website](https://developer.srgssr.ch/api-catalog/srf-weather) and generate a "bearer token".
This is described in the following instructions: [SRF instruction](https://developer.srgssr.ch/getting-started/easy-description-get-accesstoken)

After a Bearer Token is available, you can store it in the Connector project in the variable "srfWeatherConnector.Token"(under Config-->variables.yaml).
After a Bearer Token is available, you can store it in your project in the variables.yaml as the variable "srfWeatherConnector.Token" (as you can see in the Demo).
1. Register an account on [developer.srgssr.ch/](https://developer.srgssr.ch/).
2. Once logged in, click Apps on the top right and add a new app with the "+ ADD APP" button.
3. After the app is created, you will receive a Consumer Key and Consumer Secret with which you can generate the Bearer Token.
4. Store the API-Key/Token in your variables.yaml under `Variables.SrfWeatherConnector.Token`

```
@variables.yaml@
```
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.connector.srf.weather.test.Data
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.connector.srf.weather.test
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=111000
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
90 changes: 48 additions & 42 deletions srf-weather-connector-test/pom.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-test</artifactId>
<version>10.0.2-SNAPSHOT</version>
<packaging>iar</packaging>
<dependencies>
<dependency>
<groupId>com.axonivy.ivy.test</groupId>
<artifactId>unit-tester</artifactId>
<version>10.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector</artifactId>
<version>${project.version}</version>
<type>iar</type>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src_test</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.6</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-test</artifactId>
<version>10.0.2-SNAPSHOT</version>
<packaging>iar</packaging>
<dependencies>
<dependency>
<groupId>com.axonivy.ivy.test</groupId>
<artifactId>unit-tester</artifactId>
<version>10.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector</artifactId>
<version>${project.version}</version>
<type>iar</type>
</dependency>
<dependency>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-demo</artifactId>
<version>10.0.2-SNAPSHOT</version>
<type>iar</type>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src_test</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.6</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId"
project-version="1.5.0">
<wb-module deploy-name="srf-weather-connector-webTest">
<wb-resource deploy-path="/" source-path="/webContent"
tag="defaultRootSource" />
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/src" />
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/src_hd" />
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/src_wsproc" />
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/src_dataClasses" />
<property name="java-output-path"
value="/srf-weather-connector-webTest/target/classes" />
<property name="context-root"
value="srf-weather-connector-webTest" />
</wb-module>
</project-modules>
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-web-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>srf-weather-connector-webTest</artifactId>
<version>10.0.2-SNAPSHOT</version>
<packaging>iar-integration-test</packaging>
<dependencies>
<dependency>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-demo</artifactId>
<version>10.0.0-SNAPSHOT</version>
<type>iar</type>
</dependency>
<dependency>
<groupId>com.axonivy.connector.srf.weather</groupId>
<artifactId>srf-weather-connector-test</artifactId>
<version>10.0.0-SNAPSHOT</version>
<version>10.0.2-SNAPSHOT</version>
<type>iar</type>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,37 @@

import com.axonivy.ivy.webtest.IvyWebTest;
import com.axonivy.ivy.webtest.engine.EngineUrl;

import static com.axonivy.ivy.webtest.engine.EngineUrl.isDesigner;
import static com.codeborne.selenide.WebDriverConditions.urlContaining;

@IvyWebTest
public class DemoWebIT {

public static void assertCurrentUrlContains(String contains) {
webdriver().shouldHave(urlContaining(contains));
}

@BeforeEach
void beforeEach() {
open(EngineUrl.createProcessUrl("srf-weather-connector-WebTest/18A17804D90373B1/setMockConfig.ivp"));
open(EngineUrl.createProcessUrl("srf-weather-connector-demo/189FE26D94E3ECBA/start.ivp"));
open(EngineUrl.createProcessUrl("srf-weather-connector-webTest/18A17804D90373B1/setMockConfig.ivp"));
assertCurrentUrlContains(isDesigner() ? "/default-workflow/faces" : "end");
open(EngineUrl.createProcessUrl("srf-weather-connector-demo/189FE26D94E3ECBA/start.ivp"));
}

@AfterEach
void afterEach() {
open(EngineUrl.createProcessUrl("srf-weather-connector-WebTest/18A17804D90373B1/cleanupMockConfig.ivp"));
open(EngineUrl.createProcessUrl("srf-weather-connector-webTest/18A17804D90373B1/cleanupMockConfig.ivp"));

}

@Test
public void checkWeatherTitle() {
$(By.id("form:dataZip")).sendKeys("6300");
$(By.id("form:getWeatherButton")).click();
$(By.id("form:noMatchMsg")).shouldBe(hidden);
$(By.id("form:headerWeatherResult")).shouldHave(exactText("Zug"));
}

@Test
public void checkWarningMsg() {
$(By.id("form:dataZip")).sendKeys("6301456");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.connector.srf.weather.connector
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:useProjectSettings=true
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=111000
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
2 changes: 0 additions & 2 deletions srf-weather-connector/config/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Variables:
SrfWeatherConnector:
# The url for the SRF weather API
Url: https://api.srgssr.ch/srf-meteo/v2
# For testing you can use the following Variable to refer to the testing Mock API under: 'http://localhost:8081/designer/api/weatherMock'
MockUrl: http://localhost:8081/designer/api/weatherMock
# Your SRF API token
# This token serves as your authentication key for accessing the SRF API.
# [password]
Expand Down

0 comments on commit f7253d1

Please sign in to comment.