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

Commit

Permalink
merge pandamic radar from main into Release 2.28 (#1930)
Browse files Browse the repository at this point in the history
* Update maven.config (#1922)

preparation for release 2.29

* auto close json-schema InputStream (#1923)

* Bump test-containers.version from 1.17.4 to 1.17.5 (#1925)

Bumps `test-containers.version` from 1.17.4 to 1.17.5.

Updates `testcontainers` from 1.17.4 to 1.17.5
- [Release notes](https://github.com/testcontainers/testcontainers-java/releases)
- [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md)
- [Commits](testcontainers/testcontainers-java@1.17.4...1.17.5)

Updates `junit-jupiter` from 1.17.4 to 1.17.5
- [Release notes](https://github.com/testcontainers/testcontainers-java/releases)
- [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md)
- [Commits](testcontainers/testcontainers-java@1.17.4...1.17.5)

Updates `postgresql` from 1.17.4 to 1.17.5
- [Release notes](https://github.com/testcontainers/testcontainers-java/releases)
- [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md)
- [Commits](testcontainers/testcontainers-java@1.17.4...1.17.5)

---
updated-dependencies:
- dependency-name: org.testcontainers:testcontainers
  dependency-type: direct:development
  update-type: version-update:semver-patch
- dependency-name: org.testcontainers:junit-jupiter
  dependency-type: direct:development
  update-type: version-update:semver-patch
- dependency-name: org.testcontainers:postgresql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump tomcat.version from 9.0.67 to 9.0.68 (#1929)

Bumps `tomcat.version` from 9.0.67 to 9.0.68.

Updates `tomcat-embed-core` from 9.0.67 to 9.0.68

Updates `tomcat-embed-el` from 9.0.67 to 9.0.68

Updates `tomcat-annotations-api` from 9.0.67 to 9.0.68

---
updated-dependencies:
- dependency-name: org.apache.tomcat.embed:tomcat-embed-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.apache.tomcat.embed:tomcat-embed-el
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.apache.tomcat:tomcat-annotations-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* split also the retention policy by profile (#1927) (#1928)

* Protocol Buffer update for release 2.28.x at Wed Oct  5 12:10:37 UTC 2022 (#1926)

* Update from https://github.com/corona-warn-app/cwa-protocol-buffers/commit/f5a31a861483cb9d2410c81aca0bc3f8617445a2

* proposal/draft

STATISTICS_PANDEMIC_RADAR_URL

* corrected param name

* LinkCard setHeader

* dummy LinkCardFactory for new enum: PANDEMIC_RADAR_CARD

* tests for pandemic radar card

* move up

* refactoring

Co-authored-by: Hilmar Falkenberg <[email protected]>
Co-authored-by: SAP <[email protected]>

* Protocol Buffer update for release 2.28.x at Wed Oct  5 12:10:37 UTC 2022 (#1926)

* Update from https://github.com/corona-warn-app/cwa-protocol-buffers/commit/f5a31a861483cb9d2410c81aca0bc3f8617445a2

* proposal/draft

STATISTICS_PANDEMIC_RADAR_URL

* corrected param name

* LinkCard setHeader

* dummy LinkCardFactory for new enum: PANDEMIC_RADAR_CARD

* tests for pandemic radar card

* move up

* refactoring

Co-authored-by: Hilmar Falkenberg <[email protected]>
Co-authored-by: SAP <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: mfromme <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CWA Technical User <[email protected]>
Co-authored-by: SAP <[email protected]>
  • Loading branch information
5 people authored Oct 10, 2022
1 parent 50650ef commit 14d8a84
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file is auto-generated, DO NOT make any changes here
syntax = "proto3";
package app.coronawarn.server.common.protocols.internal.stats;
option java_multiple_files = true;
import "app/coronawarn/server/common/protocols/internal/stats/card_header.proto";

message LinkCard {

CardHeader header = 1;

string url = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package app.coronawarn.server.common.protocols.internal.stats;
option java_multiple_files = true;
import "app/coronawarn/server/common/protocols/internal/stats/key_figure_card.proto";
import "app/coronawarn/server/common/protocols/internal/stats/link_card.proto";

message Statistics {

Expand All @@ -11,4 +12,6 @@ message Statistics {
repeated int32 cardIdSequence = 1;

repeated KeyFigureCard keyFigureCards = 2;

repeated LinkCard linkCards = 3;
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
<io-netty.version>4.1.82.Final</io-netty.version>
<guava.version>31.1-jre</guava.version>
<jackson.version>2.13.4</jackson.version>
<test-containers.version>1.17.4</test-containers.version>
<test-containers.version>1.17.5</test-containers.version>
<postgresql.version>42.5.0</postgresql.version>
<wiremock.version>2.34.0</wiremock.version>
<httpclient.version>4.5.13</httpclient.version>
<junit.version>4.13.2</junit.version>
<tomcat.version>9.0.67</tomcat.version>
<tomcat.version>9.0.68</tomcat.version>
<findify-s3mock.version>0.2.6</findify-s3mock.version>
<checkstyle.version>10.3.4</checkstyle.version>
<semver4j.version>3.1.0</semver4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ public static class StatisticsConfig {

private String bucket;

private String pandemicRadarUrl;

public String getPandemicRadarUrl() {
return pandemicRadarUrl;
}

public void setPandemicRadarUrl(String pandemicRadarUrl) {
this.pandemicRadarUrl = pandemicRadarUrl;
}

public String getLocalStatisticPath() {
return localStatisticPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.getNameFor;

import app.coronawarn.server.common.persistence.service.StatisticsDownloadService;
import app.coronawarn.server.common.protocols.internal.stats.CardHeader;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard;
import app.coronawarn.server.common.protocols.internal.stats.LinkCard;
import app.coronawarn.server.common.protocols.internal.stats.Statistics;
import app.coronawarn.server.common.shared.util.SerializationUtils;
import app.coronawarn.server.common.shared.util.TimeUtils;
Expand Down Expand Up @@ -116,6 +118,7 @@ public Statistics constructProtobufStatistics() {
return Statistics.newBuilder()
.addAllCardIdSequence(getAllCardIdSequence())
.addAllKeyFigureCards(buildAllKeyFigureCards(jsonStringObjects))
.addAllLinkCards(buildAllLinkCards())
.build();
}
} catch (BucketNotFoundException | ConnectionException | FilePathNotFoundException | IOException ex) {
Expand All @@ -124,6 +127,12 @@ public Statistics constructProtobufStatistics() {
}
}

private Iterable<? extends LinkCard> buildAllLinkCards() {
return Collections.singleton(
LinkCard.newBuilder().setHeader(CardHeader.newBuilder().setCardId(Cards.PANDEMIC_RADAR_CARD.ordinal()).build())
.setUrl(distributionServiceConfig.getStatistics().getPandemicRadarUrl()).build());
}

private List<Integer> getAllCardIdSequence() {
String[] idSequenceArray = distributionServiceConfig.getCardIdSequence()
.replace("[", "").replace("]", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.IntensiveCareCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.JoinedIncidenceCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.KeySubmissionCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.LinkCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.ReproductionNumberCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.VaccinationDosesCardFactory;

Expand Down Expand Up @@ -64,7 +65,9 @@ public enum Cards {
/**
* Third Dose Card.
*/
BOOSTER_VACCINATED_CARD(new BoosterVaccinatedCardFactory(), "Booster Vaccinated Card");
BOOSTER_VACCINATED_CARD(new BoosterVaccinatedCardFactory(), "Booster Vaccinated Card"),

PANDEMIC_RADAR_CARD(new LinkCardFactory(), "Link Card");

/**
* Get card factory by ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@

import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.EMPTY_CARD;

import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard.Builder;
import app.coronawarn.server.services.distribution.statistics.StatisticsJsonStringObject;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class EmptyCardFactory extends HeaderCardFactory {

@Override
protected int getCardId() {
return EMPTY_CARD.ordinal();
}

@Override
protected KeyFigureCard buildKeyFigureCard(StatisticsJsonStringObject stats, Builder keyFigureBuilder) {
return keyFigureBuilder.build();
}

@Override
protected List<Optional<Object>> getRequiredFieldValues(StatisticsJsonStringObject stats) {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import app.coronawarn.server.common.protocols.internal.stats.CardHeader;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard.Builder;
import app.coronawarn.server.services.distribution.config.DistributionServiceConfig;
import app.coronawarn.server.services.distribution.statistics.StatisticsJsonStringObject;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -57,8 +59,9 @@ private void throwIfNullFieldsFound(StatisticsJsonStringObject stats) {

protected abstract int getCardId();

protected abstract KeyFigureCard buildKeyFigureCard(StatisticsJsonStringObject stats,
KeyFigureCard.Builder keyFigureBuilder);
protected KeyFigureCard buildKeyFigureCard(StatisticsJsonStringObject stats, Builder keyFigureBuilder) {
return keyFigureBuilder == null ? null : keyFigureBuilder.build();
}

/**
* Return the list of required fields to create this card. Implemented by factories. If any of the fields returned by
Expand All @@ -68,7 +71,9 @@ protected abstract KeyFigureCard buildKeyFigureCard(StatisticsJsonStringObject s
* @param stats JSON string object.
* @return List of objects to be checked if are null.
*/
protected abstract List<Optional<Object>> getRequiredFieldValues(StatisticsJsonStringObject stats);
protected List<Optional<Object>> getRequiredFieldValues(StatisticsJsonStringObject stats) {
return Collections.emptyList();
}

public void setConfig(final DistributionServiceConfig config) {
this.config = config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory;

import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.PANDEMIC_RADAR_CARD;

public class LinkCardFactory extends HeaderCardFactory {

@Override
public int getCardId() {
return PANDEMIC_RADAR_CARD.ordinal();
}
}
3 changes: 2 additions & 1 deletion services/distribution/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
eu-package-name: EUR
# Indicates whether the shifting and expiry policies are applied to all supported countries during distribution.
apply-policies-for-all-countries: false
card-id-sequence: ${STATS_CARD_ID_SEQUENCE:[10,2,8,9,1,3,4,5,6,11,7]}
card-id-sequence: ${STATS_CARD_ID_SEQUENCE:[12,999,10,2,8,9,1,3,4,5,6,11,7]}
# Local paths, that are used during the export creation.
connection-pool-size: 200
default-archive-name: export.bin
Expand Down Expand Up @@ -117,6 +117,7 @@ services:
secret-key: ${STATISTICS_FILE_SECRET_ACCESS_KEY:}
endpoint: ${STATISTICS_FILE_S3_ENDPOINT:}
bucket: ${STATISTICS_FILE_S3_BUCKET:obs-cwa-public-dev}
pandemic-radar-url: ${STATISTICS_PANDEMIC_RADAR_URL:https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/COVID-19-Trends/COVID-19-Trends.html?__blob=publicationFile#/home}

app-features:
- label: unencrypted-checkins-enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.INFECTIONS_CARD;
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.INTENSIVE_CARE_CARD;
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.KEY_SUBMISSION_CARD;
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.PANDEMIC_RADAR_CARD;
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.REPRODUCTION_NUMBER_CARD;
import static app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards.VACCINATION_DOSES_CARD;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;

import app.coronawarn.server.common.protocols.internal.stats.CardHeader;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigure;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigure.Rank;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigure.Trend;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigure.TrendSemantic;
import app.coronawarn.server.common.protocols.internal.stats.KeyFigureCard;
import app.coronawarn.server.common.protocols.internal.stats.LinkCard;
import app.coronawarn.server.services.distribution.config.DistributionServiceConfig;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.Cards;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.KeyFigureCardFactory;
import app.coronawarn.server.services.distribution.statistics.keyfigurecard.factory.MissingPropertyException;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -486,6 +492,34 @@ void testCardHasCorrectKeyFigures() {
}
}

@Nested
@EnableConfigurationProperties(value = DistributionServiceConfig.class)
@ContextConfiguration(classes = {
KeyFigureCardFactory.class}, initializers = ConfigDataApplicationContextInitializer.class)
class PandemicRadarCardTest {

@Autowired
DistributionServiceConfig distributionServiceConfig;

@Test
void pandemicRadarCardCreeationShouldReturnNull() {
KeyFigureCard keyFigureCard = figureCardFactory.createKeyFigureCard(statisticsJsonStringObject, PANDEMIC_RADAR_CARD.ordinal());
Assert.assertNotNull(keyFigureCard);
Assert.assertEquals(0, keyFigureCard.getKeyFiguresCount());
}

@Test
void pandemicRadarCardAttributeTest() {
LinkCard card = LinkCard.newBuilder()
.setHeader(CardHeader.newBuilder().setCardId(PANDEMIC_RADAR_CARD.ordinal()).build())
.setUrl(distributionServiceConfig.getStatistics().getPandemicRadarUrl()).build();
CardHeader header = card.getHeader();
Assert.assertEquals(0L, header.getUpdatedAt());
Assert.assertEquals(12, header.getCardId());
Assert.assertEquals("https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/COVID-19-Trends/COVID-19-Trends.html?__blob=publicationFile#/home", card.getUrl());
}
}

private void assertKeyFigure(KeyFigure result, double value, Rank rank, Trend trend, TrendSemantic trendSemantic,
Integer decimals) {
assertThat(result).extracting(KeyFigure::getValue, KeyFigure::getRank, KeyFigure::getTrend,
Expand Down
1 change: 1 addition & 0 deletions services/distribution/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ services:
secret-key: secretKey
endpoint: https://localhost
bucket: ${STATS_S3_BUCKET:obs-cwa-public-dev}
pandemic-radar-url: ${STATISTICS_PANDEMIC_RADAR_URL:https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Situationsberichte/COVID-19-Trends/COVID-19-Trends.html?__blob=publicationFile#/home}

app-features:
- label: unencrypted-checkins-enabled
Expand Down

0 comments on commit 14d8a84

Please sign in to comment.