Skip to content

Commit

Permalink
fix materialized view comment, update testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
mprins committed Nov 19, 2018
1 parent 50e0a50 commit e3c02c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion datamodel/extra_scripts/postgresql/207_brk_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ FROM vb_util_app_re_parent u1
JOIN kad_perceel kp ON u1.parent_identif = kp.sc_kad_identif::text
GROUP BY u1.app_re_identif, kp.sc_kad_identif;

COMMENT ON VIEW mb_util_app_re_kad_perceel
COMMENT ON MATERIALIZED VIEW mb_util_app_re_kad_perceel
IS 'commentaar view mb_util_app_re_kad_perceel:
utility view, niet bedoeld voor direct gebruik, met lijst van appartementsrechten met bijbehorend grondperceel
beschikbare kolommen:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dbunit.database.DatabaseDataSourceConnection;
import org.junit.After;

import static org.junit.Assume.assumeNotNull;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -26,50 +22,46 @@
import org.dbunit.ext.mssql.MsSqlDataTypeFactory;
import org.dbunit.ext.oracle.Oracle10DataTypeFactory;
import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

/**
* Een testcase om te kijken of het upgrade script correct is verwerkt
* Een testcase om te kijken of het upgrade script correct is verwerkt. De
* database upgrade wordt met behulp van shell scripts gedaan, deze testcase
* checked alleen de waarden in de metadata tabel.
*
* @author Mark Prins
*/
@RunWith(Parameterized.class)
public class DatabaseUpgradeTest {

private static String nextRelease;
private static String previousRelease;
private static final Log LOG = LogFactory.getLog(DatabaseUpgradeTest.class);

@Parameterized.Parameters(name = "{index}: testen database: {0}")
public static Collection params() {
return Arrays.asList(new Object[][]{
{"staging"}, {"rsgb"}, {"rsgbbgt"}
{"staging"}, {"rsgb"}, {"rsgbbgt"}
});
}

private String dbName;

public DatabaseUpgradeTest(String dbName) {
this.dbName = dbName;
}

private IDatabaseConnection db;

private static String nextRelease;
private static String previousRelease;
private static final Log LOG = LogFactory.getLog(DatabaseUpgradeTest.class);

@BeforeClass
public static void getEnvironment() {
nextRelease = System.getProperty("project.version").replace("-SNAPSHOT", "");
LOG.debug("komende release is: " + nextRelease);
// Semantic Versioning scheme (MAJOR.MINOR.PATCH)
// Semantic versioning scheme (MAJOR.MINOR.PATCH)
previousRelease = nextRelease;
int patch = Integer.parseInt(nextRelease.substring(nextRelease.lastIndexOf(".") + 1));
LOG.debug("release patch is: " + patch);
previousRelease = nextRelease.substring(0, nextRelease.lastIndexOf(".")) + "." + (patch - 1);
LOG.debug("vorige release is: " + previousRelease);

assumeTrue(previousRelease.matches("(\\d+\\.)(\\d+\\.)(\\d)"));
}

/**
Expand All @@ -80,6 +72,8 @@ public static void getEnvironment() {
public static void checkDatabaseIsProvided() {
assumeNotNull("Verwacht database omgeving te zijn aangegeven.", System.getProperty("database.properties.file"));
}
private final String dbName;
private IDatabaseConnection db;

/**
* properties uit {@code <DB smaak>.properties} en
Expand All @@ -104,6 +98,10 @@ public static void checkDatabaseIsProvided() {
*/
protected boolean isPostgis;

public DatabaseUpgradeTest(String dbName) {
this.dbName = dbName;
}

@Before
public void setUpDB() throws Exception {
this.loadProps();
Expand All @@ -122,7 +120,6 @@ public void setUpDB() throws Exception {
db.getConfig().setProperty(DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, true);
} else if (this.isPostgis) {
db.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());

} else {
fail("Geen ondersteunde database aangegegeven.");
}
Expand All @@ -136,11 +133,14 @@ public void testCurrentVersion() throws Exception {
String waarde, naam;
boolean foundVersion = false, foundUpdate = false;

for (int i = 0; i < metadata.getRowCount(); i++) {
int rowCount = metadata.getRowCount();
assertTrue("Verwacht tenminste twee records.", (rowCount >= 2));

for (int i = 0; i < rowCount; i++) {
waarde = metadata.getValue(i, "waarde").toString();
naam = metadata.getValue(i, "naam").toString();

LOG.debug(String.format("database %s, metadata tabel record: %d: naam: %s, waarde: %s",this.dbName,i,naam, waarde));
LOG.debug(String.format("database %s, metadata tabel record: %d: naam: %s, waarde: %s", this.dbName, i, naam, waarde));

if (nextRelease.equalsIgnoreCase(waarde)
&& "brmoversie".equalsIgnoreCase(naam)) {
Expand All @@ -152,8 +152,8 @@ public void testCurrentVersion() throws Exception {
foundUpdate = true;
}
}
assertTrue("Update versienummer niet correct voor "+this.dbName, foundVersion);
assertTrue("Update text niet gevonden voor "+this.dbName, foundUpdate);
assertTrue("Update versienummer niet correct voor " + this.dbName, foundVersion);
assertTrue("Update text niet gevonden voor " + this.dbName, foundUpdate);
}

@After
Expand Down
2 changes: 1 addition & 1 deletion datamodel/upgrade_scripts/1.6.1-1.6.2/postgresql/rsgb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ JOIN kad_perceel kp ON u1.parent_identif = kp.sc_kad_identif::text
GROUP BY u1.app_re_identif, kp.sc_kad_identif
WITH NO DATA;

COMMENT ON VIEW mb_util_app_re_kad_perceel
COMMENT ON MATERIALIZED VIEW mb_util_app_re_kad_perceel
IS 'commentaar view mb_util_app_re_kad_perceel:
utility view, niet bedoeld voor direct gebruik, met lijst van appartementsrechten met bijbehorend grondperceel
beschikbare kolommen:
Expand Down

0 comments on commit e3c02c0

Please sign in to comment.