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

Commit

Permalink
added test for empty views for mysql for issue #36
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cullimore committed Feb 12, 2019
1 parent 281ee23 commit f1ea57a
Show file tree
Hide file tree
Showing 8 changed files with 349 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.manywho.services.sql.suites.common.controllers.data.SaveTest;
import com.manywho.services.sql.suites.common.controllers.describe.DescribeTest;
import com.manywho.services.sql.suites.postgresql.data.*;
import com.manywho.services.sql.suites.postgresql.ZeroColumnTableTest;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
Expand All @@ -21,7 +20,6 @@
DescribeTest.class,
LoadWithoutOrderBy.class, // not for SqlServer
//postgresql
ZeroColumnTableTest.class,
DateTimeTest.class,
UuidTest.class,
CapitalLetterTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,38 @@ public void testDescribeWithTypes() throws Exception {
);
}

@Test
public void testViewWithNoColumns() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("mysql");
try (Connection connection = getSql2o().open()) {
String sql = "CREATE TABLE " + escapeTableName("deletetable") + " (id integer PRIMARY KEY);";
connection.createQuery(sql).executeUpdate();
String sql2 = "CREATE VIEW " + escapeTableName("emptyview") + " AS SELECT * FROM deletetable;";
connection.createQuery(sql2).executeUpdate();
String sql3 = "DROP TABLE " + escapeTableName("deletetable") + ";";
connection.createQuery(sql3).executeUpdate();
String sql4 = "CREATE TABLE " + escapeTableName("notemptytable") + " (id integer PRIMARY KEY, data text);";
connection.createQuery(sql4).executeUpdate();
String sql5 = "CREATE VIEW " + escapeTableName("notemptyview") + " AS SELECT * FROM notemptytable;";
connection.createQuery(sql5).executeUpdate();
}

DefaultApiRequest.describeServiceRequestAndAssertion("/metadata",
"suites/mysql/describe/with-types/metadata-empty-view-request.json",
configurationParameters(),
"suites/mysql/describe/with-types/metadata-empty-view-response.json",
dispatcher
);
}

@After
public void cleanDatabaseAfterEachTest() {
try (Connection connection = getSql2o().open()) {
String sql = "DROP VIEW IF EXISTS " + escapeTableName("emptyview") + ";";
connection.createQuery(sql).executeUpdate();
deleteTableIfExist("notemptytable", connection);
String sql2 = "DROP VIEW IF EXISTS " + escapeTableName("notemptyview") + ";";
connection.createQuery(sql2).executeUpdate();
deleteTableIfExist("country", connection);
} catch (ClassNotFoundException e) {
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,33 @@ public void testDescribeWithAliases() throws Exception {
);
}

@Test
public void testTableWithNoColumns() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("postgresql");
try (Connection connection = getSql2o().open()) {
String sql = "CREATE TABLE " + escapeTableName("emptytable") + "(id integer PRIMARY KEY);";
connection.createQuery(sql).executeUpdate();
String sql2 = "ALTER TABLE " + escapeTableName("emptytable") + " DROP COLUMN id;";
connection.createQuery(sql2).executeUpdate();
String sql3 = "CREATE TABLE " + escapeTableName("notemptytable") + "(id integer PRIMARY KEY, data text);";
connection.createQuery(sql3).executeUpdate();
}

DefaultApiRequest.describeServiceRequestAndAssertion("/metadata",
"suites/postgresql/describe/with-types/metadata-empty-table-request.json",
configurationParameters(),
"suites/postgresql/describe/with-types/metadata-empty-table-response.json",
dispatcher
);
}

@After
public void cleanDatabaseAfterEachTest() {
try (Connection connection = getSql2o().open()) {
deleteTableIfExist("country", connection);
deleteTableIfExist("country2", connection);
deleteTableIfExist("emptytable", connection);
deleteTableIfExist("notemptytable", connection);
deleteTableIfExist("timetest", connection);
} catch (ClassNotFoundException e) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"culture": null,
"uri": null,
"configurationValues": [
{
"developerName": "No SSL",
"contentValue": null,
"contentType": "ContentBoolean",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Password",
"contentValue": null,
"contentType": "ContentPassword",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Server Public Certificate",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": false
},
{
"developerName": "Database Type",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Database Schema",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Database Name",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Port",
"contentValue": null,
"contentType": "ContentNumber",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Host",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
},
{
"developerName": "Username",
"contentValue": null,
"contentType": "ContentString",
"typeElementDeveloperName": null,
"ordinal": 0,
"required": true
}
],
"providesAutoBinding": false,
"providesDatabase": true,
"providesFiles": false,
"providesIdentity": false,
"providesListening": false,
"providesLogic": false,
"providesNotifications": false,
"providesSmartSave": false,
"providesSocial": false,
"providesSharing": false,
"providesViews": false,
"providesVoting": false,
"actions": [],
"install": {
"typeElements": [
{
"elementType": "TYPE",
"developerName": "notemptytable",
"developerSummary": null,
"id": null,
"serviceElementId": null,
"properties": [
{
"id": null,
"developerName": "data",
"contentFormat": null,
"contentType": "ContentString",
"typeElementId": null,
"typeElementDeveloperName": null
},
{
"id": null,
"developerName": "id",
"contentFormat": null,
"contentType": "ContentNumber",
"typeElementId": null,
"typeElementDeveloperName": null
}
],
"bindings": [
{
"id": null,
"developerName": "notemptytable",
"developerSummary": "The binding for notemptytable",
"databaseTableName": "notemptytable",
"serviceElementId": null,
"propertyBindings": [
{
"databaseFieldName": "data",
"typeElementPropertyId": null,
"typeElementPropertyDeveloperName": "data",
"databaseContentType": "LONGVARCHAR"
},
{
"databaseFieldName": "id",
"typeElementPropertyId": null,
"typeElementPropertyDeveloperName": "id",
"databaseContentType": "INTEGER"
}
]
}
],
"updateByName": false
},
{
"elementType": "TYPE",
"developerName": "notemptyview",
"developerSummary": null,
"id": null,
"serviceElementId": null,
"properties": [
{
"id": null,
"developerName": "data",
"contentFormat": null,
"contentType": "ContentString",
"typeElementId": null,
"typeElementDeveloperName": null
},
{
"id": null,
"developerName": "id",
"contentFormat": null,
"contentType": "ContentNumber",
"typeElementId": null,
"typeElementDeveloperName": null
}
],
"bindings": [
{
"id": null,
"developerName": "notemptyview",
"developerSummary": "The binding for notemptyview",
"databaseTableName": "notemptyview",
"serviceElementId": null,
"propertyBindings": [
{
"databaseFieldName": "data",
"typeElementPropertyId": null,
"typeElementPropertyDeveloperName": "data",
"databaseContentType": "LONGVARCHAR"
},
{
"databaseFieldName": "id",
"typeElementPropertyId": null,
"typeElementPropertyDeveloperName": "id",
"databaseContentType": "INTEGER"
}
]
}
],
"updateByName": false
}
]
}
}
Loading

0 comments on commit f1ea57a

Please sign in to comment.