From a43776e5dc24987e57c7db0cba7597cd48237d81 Mon Sep 17 00:00:00 2001 From: NMerz Date: Tue, 6 Oct 2020 21:54:04 -0400 Subject: [PATCH] Enforce schema matching Ensure all Lambdas and tests follow the current db schema --- Lambdas/Lists/ListEntry/src/ListEntryAdder.java | 3 ++- .../app/src/main/java/com/example/listify/MainActivity.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lambdas/Lists/ListEntry/src/ListEntryAdder.java b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java index 2145cd5..6154025 100644 --- a/Lambdas/Lists/ListEntry/src/ListEntryAdder.java +++ b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java @@ -1,6 +1,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.sql.Timestamp; import java.time.Instant; import java.time.ZoneOffset; import java.util.HashMap; @@ -25,7 +26,7 @@ public class ListEntryAdder implements CallHandler { statement.setInt(1, (Integer) bodyMap.get("productID")); statement.setInt(2, (Integer) bodyMap.get("listID")); statement.setInt(3, (Integer) bodyMap.get("quantity")); - statement.setObject(4, Instant.now().atZone(ZoneOffset.UTC).toLocalDateTime()); + statement.setTimestamp(4, Timestamp.from(Instant.now())); statement.setBoolean(5, (Boolean) bodyMap.get("purchased")); System.out.println(statement); statement.executeUpdate(); diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index ec57389..c7b072d 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -84,7 +84,7 @@ public class MainActivity extends AppCompatActivity { //The name is the only part of this that is used, the rest is generated by the Lambda. List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli()); //Everything except addedDate is used for ItemEntry - ListEntry entry = new ListEntry(1, 1, new Random().nextInt(), Instant.now().toEpochMilli(),false); + ListEntry entry = new ListEntry(1, 4, Math.abs(new Random().nextInt()), Instant.now().toEpochMilli(),false); SynchronousReceiver idReceiver = new SynchronousReceiver<>(); try { requestor.postObject(testList, idReceiver, idReceiver);