-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
172c2ce
commit d51d6c8
Showing
7 changed files
with
100 additions
and
26 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
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
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
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
12 changes: 12 additions & 0 deletions
12
dpppt-additionalinfo-backend/src/main/resources/db/migration/pgsql_cluster/afterMigrate.sql
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,12 @@ | ||
create or replace procedure reassign_objects_ownership() LANGUAGE 'plpgsql' | ||
as $BODY$ | ||
BEGIN | ||
IF EXISTS(SELECT FROM pg_catalog.pg_roles where rolname = current_user || '_role_full') THEN | ||
execute format('reassign owned by %s to %s_role_full', user, current_database()); | ||
END IF; | ||
END $BODY$; | ||
|
||
|
||
call reassign_objects_ownership(); | ||
|
||
drop procedure reassign_objects_ownership(); |
50 changes: 50 additions & 0 deletions
50
...nfo-backend/src/test/java/org/dpppt/additionalinfo/backend/ws/HistoryDataServiceTest.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,50 @@ | ||
/* | ||
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package org.dpppt.additionalinfo.backend.ws; | ||
|
||
import static org.junit.Assert.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDate; | ||
|
||
import org.dpppt.additionalinfo.backend.ws.data.HistoryDataService; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
@SpringBootTest | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ComponentScan(basePackages = {"org.dpppt.additionalinfo.backend.ws.config"}) | ||
@ActiveProfiles("postgres-test") | ||
public class HistoryDataServiceTest { | ||
|
||
@Autowired HistoryDataService historyDataService; | ||
|
||
@Test | ||
public void testUpsertFindAndDelete() { | ||
LocalDate now = LocalDate.now(); | ||
for (int i = 0; i < 100; i++) { | ||
historyDataService.upsertLatestSevenDayAvgForDay(10, now.minusDays(i)); | ||
} | ||
for (int i = 0; i < 100; i++) { | ||
assertEquals(10, historyDataService.findLatestSevenDayAvgForDay(now.minusDays(i))); | ||
} | ||
historyDataService.removeBefore(now.minusDays(10)); | ||
|
||
assertNull(historyDataService.findLatestSevenDayAvgForDay(now.minusDays(11))); | ||
assertEquals(10, historyDataService.findLatestSevenDayAvgForDay(now.minusDays(10))); | ||
} | ||
|
||
} |
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