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

Commit

Permalink
issue #46 updated tests to work with postgres and sqlserver
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cullimore committed Mar 5, 2019
1 parent 77d4fbf commit d3b51a7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
UuidTest.class,
CapitalLetterTest.class,
AutoIncrementTest.class,
DeleteTest.class,
com.manywho.services.sql.suites.postgresql.data.LoadTest.class,
com.manywho.services.sql.suites.postgresql.data.DeleteTest.class,
com.manywho.services.sql.suites.postgresql.data.SaveTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ public void testDeleteDataByExternalId() throws Exception {
public void testDeleteMultipleDataByExternalId() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("postgresql");
try (Connection connection = getSql2o().open()) {
String sqlCreateTable = "CREATE TABLE " + escapeTableName("testtable") +
"(" +
"id integer primary key auto_increment," +
"data text" +
");";
String sqlCreateTable = "CREATE TABLE " + escapeTableName("testtable") + "(id integer primary key, data text);";
connection.createQuery(sqlCreateTable).executeUpdate();

String sqlInsert = "INSERT INTO " + escapeTableName("testtable")+ " (data) VALUES ('test1'), ('test2');";
String sqlInsert = "INSERT INTO " + escapeTableName("testtable")+ " (id, data) VALUES (1, 'test1'), (2, 'test2');";
connection.createQuery(sqlInsert).executeUpdate();
} catch (Exception e) {
throw e;
Expand Down Expand Up @@ -90,14 +86,10 @@ public void testDeleteMultipleDataByExternalId() throws Exception {
public void testDeleteMultipleMissingDataByExternalId() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("postgresql");
try (Connection connection = getSql2o().open()) {
String sqlCreateTable = "CREATE TABLE " + escapeTableName("testtable") +
"(" +
"id integer primary key auto_increment," +
"data text" +
");";
String sqlCreateTable = "CREATE TABLE " + escapeTableName("testtable") + "(id integer primary key, data text);";
connection.createQuery(sqlCreateTable).executeUpdate();

String sqlInsert = "INSERT INTO " + escapeTableName("testtable")+ "(data) VALUES ('test1');";
String sqlInsert = "INSERT INTO " + escapeTableName("testtable")+ "(id, data) VALUES (1, 'test1');";
connection.createQuery(sqlInsert).executeUpdate();
} catch (Exception e) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ public void testUpdate() throws Exception {
public void testUpdateMissingId () throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("mysql");

try (Connection connection = getSql2o().open()) {
String sql = "CREATE TABLE " + escapeTableName("testtable") + " (id integer primary key auto_increment NOT NULL, data text);";
connection.createQuery(sql).executeUpdate();
}
createTestTable();

DefaultApiRequest.saveDataRequestAndAssertion("/data",
"suites/common/data/save/update/update-missing-request.json",
Expand All @@ -88,7 +85,7 @@ public void testUpdateMissingId () throws Exception {

private void createTestTable() throws Exception {
try (Connection connection = getSql2o().open()) {
String sql = "CREATE TABLE " + escapeTableName("testtable") + " (id integer primary key auto_increment NOT NULL, data text);";
String sql = "CREATE TABLE " + escapeTableName("testtable") + " (id integer primary key NOT NULL, data text);";
connection.createQuery(sql).executeUpdate();
}
}
Expand Down Expand Up @@ -122,7 +119,7 @@ private void assertCountOfTestTable (int expected) throws Exception {
}

@Test
public void createMulitipleTest() throws Exception {
public void createMultipleTest() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("postgresql");

createTestTable();
Expand All @@ -136,13 +133,13 @@ public void createMulitipleTest() throws Exception {
}

@Test
public void updateMulitipleTest() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("postgresql");
public void updateMultipleTest() throws Exception {
DbConfigurationTest.setPropertiesIfNotInitialized("mysql");

createTestTable();

insertToTestTable("first");
insertToTestTable("second");
insertToTestTable(1,"first");
insertToTestTable(2,"second");


DefaultApiRequest.saveDataRequestAndAssertion("/data",
Expand All @@ -159,7 +156,7 @@ public void updateAndCreateTest() throws Exception {

createTestTable();

insertToTestTable("first");
insertToTestTable(1,"first");

DefaultApiRequest.saveDataRequestAndAssertion("/data",
"suites/common/data/save/createAndUpdate/create-update-request.json",
Expand All @@ -175,7 +172,7 @@ public void updateMultipleMissingId() throws Exception {

createTestTable();

insertToTestTable("first");
insertToTestTable(1,"first");

DefaultApiRequest.saveDataRequestAndAssertion("/data",
"suites/common/data/save/update/update-multiple-missing-request.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
{
"contentFormat": null,
"contentType": "ContentNumber",
"contentValue": "0",
"contentValue": "1",
"developerName": "id",
"objectData": null,
"typeElementId": null,
Expand Down Expand Up @@ -167,7 +167,7 @@
{
"contentFormat": null,
"contentType": "ContentNumber",
"contentValue": "1",
"contentValue": "2",
"developerName": "id",
"objectData": null,
"typeElementId": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
{
"contentFormat": null,
"contentType": "ContentNumber",
"contentValue": "",
"contentValue": "2",
"developerName": "id",
"objectData": null,
"typeElementId": null,
Expand Down

0 comments on commit d3b51a7

Please sign in to comment.