Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
add endpoint and mock. refactor localized collections as maps
Browse files Browse the repository at this point in the history
  • Loading branch information
ubhaller committed May 18, 2021
1 parent 7158baa commit 1ea81d2
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package ch.admin.bag.covidcertificate.backend.config.shared.helper;

import ch.admin.bag.covidcertificate.backend.config.shared.model.Faq;
import ch.admin.bag.covidcertificate.backend.config.shared.model.FaqEntry;
import ch.admin.bag.covidcertificate.backend.config.shared.model.InfoBox;
import ch.admin.bag.covidcertificate.backend.config.shared.model.Language;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MockHelper {
public static Map<Language, Faq> getWorksMock() {
Map<Language, Faq> works = new HashMap<>();
for (Language language : Language.values()) {
Faq faq = new Faq();
faq.setFaqTitle("Wie funktioniert die App?");
faq.setFaqSubTitle(
"Hier steht eine kurze Zusammenfassung. Das ist aber erst mal nur Blindtext. Das muss man dann noch ausformulieren und noch ein bisschen.");
faq.setFaqIconIos("ic-how-it-works-image");
faq.setFaqIconAndroid("ic_how_it_works_image");
faq.setFaqEntries(getWorksFaqEntriesMock());
works.put(language, faq);
}
return works;
}

private static List<FaqEntry> getWorksFaqEntriesMock() {
return List.of(
getFaqEntryMock("Wie kann ich ein Covid-Zertifikat zur App hinzufügen?"),
getFaqEntryMock("Können auch mehrere Zertifikate hinzugefügt werden?"),
getFaqEntryMock("Wie sehe ich, ob mein Zertifikat gültig ist?"),
getFaqEntryMock("Wie sind meine Daten geschützt?"),
getFaqEntryMock("Welche Daten sind im QR-Code enthalten?"));
}

private static FaqEntry getFaqEntryMock(String title) {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle(title);
faqEntry.setText("Hier steht ein Text");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

public static Map<Language, Faq> getQuestionsMock() {
Map<Language, Faq> questions = new HashMap<>();
for (Language language : Language.values()) {
Faq faq = new Faq();
faq.setFaqTitle("Was sind Covid-Zertifikate?");
faq.setFaqSubTitle(
"Das Covid-Zertifikat ist eine Möglichkeit eine Covid-19-Impfung, eine durchgemachte Erkrankung oder ein negatives Testergebnis fälschungssicher zu dokumentieren.");
faq.setFaqIconIos("ic-faq-image");
faq.setFaqIconAndroid("ic_faq_image");
faq.setFaqEntries(getQuestionFaqEntriesMock());
questions.put(language, faq);
}
return questions;
}

private static List<FaqEntry> getQuestionFaqEntriesMock() {
return List.of(
getFaqEntry0Mock(),
getFaqEntry1Mock(),
getFaqEntry2Mock(),
getFaqEntry3Mock(),
getFaqEntry4Mock());
}

private static FaqEntry getFaqEntry0Mock() {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle("Wann und wo kann ich ein Covid-Zertifikat erhalten?");
faqEntry.setText("Hier steht ein Text");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

private static FaqEntry getFaqEntry1Mock() {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle("Wie kann ich ein Covid-Zertifikat vorweisen?");
faqEntry.setText("Hier steht ein Text");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

private static FaqEntry getFaqEntry2Mock() {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle("Wo sind meine Daten gespeichert?");
faqEntry.setText("Hier steht ein Text");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

private static FaqEntry getFaqEntry3Mock() {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle("Wie werden Missbrauch und Fälschung verhindert?");
faqEntry.setText("Hier steht ein Text");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

private static FaqEntry getFaqEntry4Mock() {
FaqEntry faqEntry = new FaqEntry();
faqEntry.setTitle("Was passiert, wenn ich mein Covid-Zertifikat verliere?");
faqEntry.setText(
"Ihr Covid-Zertifikat wird in keinem zentralen System gespeichert. Es befindet sich ausschliesslich in Ihrem Besitz. Bewahren Sie das Covid-Zertifikat auf Papier deshalb sorgfältig auf.");
faqEntry.setIconAndroid(null);
faqEntry.setIconIos(null);
faqEntry.setLinkTitle(null);
faqEntry.setLinkUrl(null);
return faqEntry;
}

public static Map<Language, InfoBox> getInfoBoxMock() {
Map<Language, InfoBox> infoBoxes = new HashMap<>();
for (Language language : Language.values()) {
InfoBox infoBox = new InfoBox();
infoBox.setTitle("Noch keinen Covidcode?");
infoBox.setMsg(
"Sie wurden positiv getestet (PCR-Test oder Antigen-Schnelltest) und haben nach 4h noch keinen Covidcode erhalten?\nDann kontaktieren Sie die Infoline Coronavirus:");
infoBox.setUrl("tel:+41583877780");
infoBox.setUrlTitle("+41 58 387 77 80");
infoBox.setIsDismissible(false);
infoBoxes.put(language, infoBox);
}
return infoBoxes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import ch.ubique.openapi.docannotations.Documentation;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
@Documentation(description = "ConfigResponse description")
Expand All @@ -22,14 +23,14 @@ public class ConfigResponse {
"Blocks the app and shows a link to the app-store. The user can only continue once he updated the app")
private boolean forceUpdate = false;

@Documentation(description = "Holds a message translated in different languages")
private InfoBoxCollection infoBox = null;
@Documentation(description = "Holds an info box for every language")
private Map<Language, InfoBox> infoBox = null;

@Documentation(description = "Holds covid-certificate FAQ parameters")
private FaqCollection questions = null;
@Documentation(description = "Holds covid-certificate FAQ parameters by language")
private Map<Language, Faq> questions = null;

@Documentation(description = "Holds how-it-works FAQ parameters")
private FaqCollection works = null;
@Documentation(description = "Holds how-it-works FAQ parameters by language")
private Map<Language, Faq> works = null;

public boolean isForceUpdate() {
return forceUpdate;
Expand All @@ -39,27 +40,27 @@ public void setForceUpdate(boolean forceUpdate) {
this.forceUpdate = forceUpdate;
}

public InfoBoxCollection getInfoBox() {
public Map<Language, InfoBox> getInfoBox() {
return infoBox;
}

public void setInfoBox(InfoBoxCollection infoBox) {
public void setInfoBox(Map<Language, InfoBox> infoBox) {
this.infoBox = infoBox;
}

public FaqCollection getQuestions() {
public Map<Language, Faq> getQuestions() {
return questions;
}

public void setQuestions(FaqCollection questions) {
public void setQuestions(Map<Language, Faq> questions) {
this.questions = questions;
}

public FaqCollection getWorks() {
public Map<Language, Faq> getWorks() {
return works;
}

public void setWorks(FaqCollection works) {
public void setWorks(Map<Language, Faq> works) {
this.works = works;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class FaqEntry {

private String title;
private String text;
private String iconAndroid = "";
private String iconIos = "";

/* optional */
private String iconAndroid;
private String iconIos;
private String linkTitle;
private String linkUrl;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.admin.bag.covidcertificate.backend.config.shared.model;

import com.fasterxml.jackson.annotation.JsonValue;

public enum Language {
DE("de"),
EN("en"),
FR("fr"),
IT("it");

private String key;

Language(String key) {
this.key = key;
}

@JsonValue
public String getKey() {
return key;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### config
GET {{verifierBaseUrl}}/v1/verifier/config?appversion={{appversion}}&osversion={{osversion}}&buildnr={{buildnr}}
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### config
GET {{walletBaseUrl}}/v1/wallet/config?appversion={{appversion}}&osversion={{osversion}}&buildnr={{buildnr}}
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
{
"local": {
"baseUrl": "localhost:8080"
"walletBaseUrl": "localhost:8080",
"verifierBaseUrl": "localhost:8081",
"appversion": "ios-1.1.0",
"osversion": "ios14.1",
"buildnr": "ios-210119.1234.123"
},
"dev": {
"baseUrl": "TODO"
"walletBaseUrl": "TODO",
"verifierBaseUrl": "TODO",
"appversion": "ios-1.1.0",
"osversion": "ios14.1",
"buildnr": "ios-210119.1234.123"
},
"abn": {
"baseUrl": "TODO"
"walletBaseUrl": "TODO",
"verifierBaseUrl": "TODO",
"appversion": "ios-1.1.0",
"osversion": "ios14.1",
"buildnr": "ios-210119.1234.123"
},
"prod": {
"baseUrl": "TODO"
"walletBaseUrl": "TODO",
"verifierBaseUrl": "TODO",
"appversion": "ios-1.1.0",
"osversion": "ios14.1",
"buildnr": "ios-210119.1234.123"
}
}
Loading

0 comments on commit 1ea81d2

Please sign in to comment.