-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable mock responses for forceupdate and infobox through profiles, by overriding the controller with the mocked responses. This is easier to maintain and we do not need to create mock/test releases each time.
- Loading branch information
1 parent
bde9c8b
commit 53f805d
Showing
7 changed files
with
241 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...n/java/org/dpppt/switzerland/backend/sdk/config/ws/config/mock/MockForceUpdateConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.dpppt.switzerland.backend.sdk.config.ws.config.mock; | ||
|
||
import org.dpppt.switzerland.backend.sdk.config.ws.controller.GaenConfigController; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import ch.ubique.openapi.docannotations.Documentation; | ||
|
||
@Configuration | ||
@Profile("mock-forceupdate") | ||
public class MockForceUpdateConfig { | ||
|
||
|
||
@Bean | ||
@Primary | ||
public GaenConfigController gaenConfigController(Messages messages) { | ||
return new MockInfoBoxController(messages); | ||
} | ||
|
||
public class MockInfoBoxController extends GaenConfigController { | ||
|
||
public MockInfoBoxController(Messages messages) { | ||
super(messages); | ||
} | ||
|
||
@Override | ||
public @Documentation(description = "Read latest configuration and messages, depending on the version of the phone and the app.", responses = "200 => ConfigResponse structure with eventual notifications and epidemic parameters") ResponseEntity<ConfigResponse> getConfig( | ||
@Documentation(description = "Version of the App installed", example = "ios-1.0.7") String appversion, | ||
@Documentation(description = "Version of the OS", example = "ios13.6") String osversion, | ||
@Documentation(description = "Build number of the app", example = "ios-200619.2333.175") String buildnr) { | ||
ResponseEntity<ConfigResponse> response = super.getConfig(appversion, osversion, buildnr); | ||
response.getBody().setForceUpdate(true);; | ||
return response; | ||
} | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/mock/MockInfoBoxConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.dpppt.switzerland.backend.sdk.config.ws.config.mock; | ||
|
||
import org.dpppt.switzerland.backend.sdk.config.ws.controller.GaenConfigController; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.helper.MockHelper; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import ch.ubique.openapi.docannotations.Documentation; | ||
|
||
@Configuration | ||
@Profile("mock-infobox") | ||
public class MockInfoBoxConfig { | ||
|
||
|
||
@Bean | ||
@Primary | ||
public GaenConfigController gaenConfigController(Messages messages) { | ||
return new MockInfoBoxController(messages); | ||
} | ||
|
||
public class MockInfoBoxController extends GaenConfigController { | ||
|
||
public MockInfoBoxController(Messages messages) { | ||
super(messages); | ||
} | ||
|
||
@Override | ||
public @Documentation(description = "Read latest configuration and messages, depending on the version of the phone and the app.", responses = "200 => ConfigResponse structure with eventual notifications and epidemic parameters") ResponseEntity<ConfigResponse> getConfig( | ||
@Documentation(description = "Version of the App installed", example = "ios-1.0.7") String appversion, | ||
@Documentation(description = "Version of the OS", example = "ios13.6") String osversion, | ||
@Documentation(description = "Build number of the app", example = "ios-200619.2333.175") String buildnr) { | ||
ResponseEntity<ConfigResponse> response = super.getConfig(appversion, osversion, buildnr); | ||
response.getBody().setInfoBox(MockHelper.mockConfigResponseWithInfoBox(true).getInfoBox()); | ||
return response; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/helper/MockHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package org.dpppt.switzerland.backend.sdk.config.ws.helper; | ||
|
||
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBox; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBoxCollection; | ||
import org.dpppt.switzerland.backend.sdk.config.ws.model.SDKConfig; | ||
|
||
public class MockHelper { | ||
|
||
public static ConfigResponse mockConfigResponseWithInfoBox(boolean dismissible) { | ||
ConfigResponse configResponse = new ConfigResponse(); | ||
|
||
InfoBox infoBoxde = new InfoBox(); | ||
infoBoxde.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz DE"); | ||
infoBoxde.setTitle("Hinweis DE"); | ||
infoBoxde.setUrlTitle("Und ein externer Link DE"); | ||
infoBoxde.setUrl("https://www.bag.admin.ch/bag/de/home.html"); | ||
infoBoxde.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxfr = new InfoBox(); | ||
infoBoxfr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz FR"); | ||
infoBoxfr.setTitle("Hinweis FR"); | ||
infoBoxfr.setUrlTitle("Und ein externer Link FR"); | ||
infoBoxfr.setUrl("https://www.bag.admin.ch/bag/fr/home.html"); | ||
infoBoxfr.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxit = new InfoBox(); | ||
infoBoxit.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz IT"); | ||
infoBoxit.setTitle("Hinweis IT"); | ||
infoBoxit.setUrlTitle("Und ein externer Link IT"); | ||
infoBoxit.setUrl("https://www.bag.admin.ch/bag/it/home.html"); | ||
infoBoxit.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxen = new InfoBox(); | ||
infoBoxen.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz EN"); | ||
infoBoxen.setTitle("Hinweis EN"); | ||
infoBoxen.setUrlTitle("Und ein externer Link EN"); | ||
infoBoxen.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxen.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxpt = new InfoBox(); | ||
infoBoxpt.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz PT"); | ||
infoBoxpt.setTitle("Hinweis PT"); | ||
infoBoxpt.setUrlTitle("Und ein externer Link PT"); | ||
infoBoxpt.setUrl("https://www.bag.admin.ch/bag/pt/home.html"); | ||
infoBoxpt.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxes = new InfoBox(); | ||
infoBoxes.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz ES"); | ||
infoBoxes.setTitle("Hinweis ES"); | ||
infoBoxes.setUrlTitle("Und ein externer Link ES"); | ||
infoBoxes.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxes.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxsq = new InfoBox(); | ||
infoBoxsq.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SQ"); | ||
infoBoxsq.setTitle("Hinweis SQ"); | ||
infoBoxsq.setUrlTitle("Und ein externer Link SQ"); | ||
infoBoxsq.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxsq.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxbs = new InfoBox(); | ||
infoBoxbs.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz BS"); | ||
infoBoxbs.setTitle("Hinweis BS"); | ||
infoBoxbs.setUrlTitle("Und ein externer Link BS"); | ||
infoBoxbs.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxbs.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxhr = new InfoBox(); | ||
infoBoxhr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz HR"); | ||
infoBoxhr.setTitle("Hinweis HR"); | ||
infoBoxhr.setUrlTitle("Und ein externer Link HR"); | ||
infoBoxhr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxhr.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxrm = new InfoBox(); | ||
infoBoxrm.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz RM"); | ||
infoBoxrm.setTitle("Hinweis RM"); | ||
infoBoxrm.setUrlTitle("Und ein externer Link RM"); | ||
infoBoxrm.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxrm.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxsr = new InfoBox(); | ||
infoBoxsr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SR"); | ||
infoBoxsr.setTitle("Hinweis SR"); | ||
infoBoxsr.setUrlTitle("Und ein externer Link SR"); | ||
infoBoxsr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxsr.setIsDismissible(dismissible); | ||
|
||
InfoBox Infoboxtr = new InfoBox(); | ||
Infoboxtr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz TR"); | ||
Infoboxtr.setTitle("Hinweis TR"); | ||
Infoboxtr.setUrlTitle("Und ein externer Link TR"); | ||
Infoboxtr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
Infoboxtr.setIsDismissible(dismissible); | ||
|
||
InfoBox infoBoxti = new InfoBox(); | ||
infoBoxti.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz TI"); | ||
infoBoxti.setTitle("Hinweis TI"); | ||
infoBoxti.setUrlTitle("Und ein externer Link TI"); | ||
infoBoxti.setUrl("https://www.bag.admin.ch/bag/en/home.html"); | ||
infoBoxti.setIsDismissible(dismissible); | ||
|
||
InfoBoxCollection collection = new InfoBoxCollection(); | ||
collection.setDeInfoBox(infoBoxde); | ||
collection.setEnInfoBox(infoBoxen); | ||
collection.setFrInfoBox(infoBoxfr); | ||
collection.setItInfoBox(infoBoxit); | ||
collection.setPtInfoBox(infoBoxpt); | ||
collection.setEsInfoBox(infoBoxes); | ||
collection.setSqInfoBox(infoBoxsq); | ||
collection.setHrInfoBox(infoBoxhr); | ||
collection.setBsInfoBox(infoBoxbs); | ||
collection.setRmInfoBox(infoBoxrm); | ||
collection.setSrInfoBox(infoBoxsr); | ||
collection.setTrInfobox(Infoboxtr); | ||
collection.setTiInfobox(infoBoxti); | ||
|
||
configResponse.setInfoBox(collection); | ||
|
||
return configResponse; | ||
} | ||
} |
Oops, something went wrong.