From 81b4673766c1fea78523cde26bf61140dd04289c Mon Sep 17 00:00:00 2001 From: NMerz Date: Sat, 3 Oct 2020 23:00:19 -0400 Subject: [PATCH] Lamdba Integration Test Lamdbas with full pipeline of client through database --- Lambdas/Lists/List/src/ItemEntry.java | 4 +- Lambdas/Lists/List/src/List.java | 26 ++-- Lambdas/Lists/List/src/ListAdder.java | 13 +- Lambdas/Lists/List/src/ListGetter.java | 12 +- .../src/ListEntryAdder.java} | 6 +- .../src/ListEntryDELETE.java} | 4 +- .../src/ListEntryDeleter.java} | 4 +- .../src/ListEntryPOST.java} | 4 +- Lambdas/Lists/src/main/java/BasicHandler.java | 2 +- .../java/com/example/listify/AuthManager.java | 7 ++ .../main/java/com/example/listify/Item.java | 44 ------- .../main/java/com/example/listify/List.java | 8 -- .../com/example/listify/MainActivity.java | 101 +++++++++------ .../java/com/example/listify/Requestor.java | 17 ++- .../java/com/example/listify/data/Item.java | 116 ++++++++++++++++++ .../java/com/example/listify/data/List.java | 70 +++++++++++ .../com/example/listify/data/ListEntry.java | 70 +++++++++++ Tooling/EndpointSetup.sh | 2 +- 18 files changed, 386 insertions(+), 124 deletions(-) rename Lambdas/Lists/{Item/src/ItemAdder.java => ListEntry/src/ListEntryAdder.java} (87%) rename Lambdas/Lists/{Item/src/ItemDELETE.java => ListEntry/src/ListEntryDELETE.java} (57%) rename Lambdas/Lists/{Item/src/ItemDeleter.java => ListEntry/src/ListEntryDeleter.java} (89%) rename Lambdas/Lists/{Item/src/ItemPOST.java => ListEntry/src/ListEntryPOST.java} (57%) delete mode 100644 Listify/app/src/main/java/com/example/listify/Item.java delete mode 100644 Listify/app/src/main/java/com/example/listify/List.java create mode 100644 Listify/app/src/main/java/com/example/listify/data/Item.java create mode 100644 Listify/app/src/main/java/com/example/listify/data/List.java create mode 100644 Listify/app/src/main/java/com/example/listify/data/ListEntry.java diff --git a/Lambdas/Lists/List/src/ItemEntry.java b/Lambdas/Lists/List/src/ItemEntry.java index 513d4ae..f03e910 100644 --- a/Lambdas/Lists/List/src/ItemEntry.java +++ b/Lambdas/Lists/List/src/ItemEntry.java @@ -3,11 +3,13 @@ import java.sql.SQLException; import java.time.LocalDateTime; public class ItemEntry { + Integer listID; Integer productID; Integer quantity; LocalDateTime addedDate; Boolean purchased; - public ItemEntry(ResultSet listRow) throws SQLException { + public ItemEntry(Integer listID, ResultSet listRow) throws SQLException { + this.listID = listID; productID = listRow.getInt(1); quantity = listRow.getInt(2); addedDate = listRow.getObject(3, LocalDateTime.class); diff --git a/Lambdas/Lists/List/src/List.java b/Lambdas/Lists/List/src/List.java index 5f9c4f5..1216c26 100644 --- a/Lambdas/Lists/List/src/List.java +++ b/Lambdas/Lists/List/src/List.java @@ -1,5 +1,6 @@ import java.sql.ResultSet; import java.sql.SQLException; +import java.time.Instant; import java.time.LocalDateTime; import java.util.ArrayList; @@ -7,14 +8,14 @@ public class List { Integer itemID; String name; String owner; - LocalDateTime lastUpdated; + long lastUpdated; ArrayList entries; public List(ResultSet listRow) throws SQLException { - itemID = listRow.getInt(1); - name = listRow.getString(2); - owner = listRow.getString(3); - lastUpdated = listRow.getObject(4, LocalDateTime.class); + itemID = listRow.getInt("listID"); + name = listRow.getString("name"); + owner = listRow.getString("owner"); + lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli(); entries = new ArrayList<>(); } @@ -22,6 +23,17 @@ public class List { entries.add(entry); } + @Override + public String toString() { + return "List{" + + "itemID=" + itemID + + ", name='" + name + '\'' + + ", owner='" + owner + '\'' + + ", lastUpdated=" + lastUpdated + + ", entries=" + entries + + '}'; + } + public ItemEntry[] getEntries() { return entries.toArray(new ItemEntry[entries.size()]); } @@ -50,11 +62,11 @@ public class List { this.owner = owner; } - public LocalDateTime getLastUpdated() { + public long getLastUpdated() { return lastUpdated; } - public void setLastUpdated(LocalDateTime lastUpdated) { + public void setLastUpdated(long lastUpdated) { this.lastUpdated = lastUpdated; } } diff --git a/Lambdas/Lists/List/src/ListAdder.java b/Lambdas/Lists/List/src/ListAdder.java index eb56e36..011cbc9 100644 --- a/Lambdas/Lists/List/src/ListAdder.java +++ b/Lambdas/Lists/List/src/ListAdder.java @@ -1,6 +1,4 @@ -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; +import java.sql.*; import java.time.Instant; import java.time.ZoneOffset; import java.util.HashMap; @@ -20,13 +18,16 @@ public class ListAdder implements CallHandler { public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { Connection connection = connector.getConnection(); - PreparedStatement statement = connection.prepareStatement(LIST_CREATE); + PreparedStatement statement = connection.prepareStatement(LIST_CREATE, Statement.RETURN_GENERATED_KEYS); statement.setString(1, bodyMap.get("name").toString());//Needs safe checking statement.setString(2, cognitoID); - statement.setObject(3, Instant.now().atZone(ZoneOffset.UTC).toLocalDateTime()); + statement.setTimestamp(3, Timestamp.from(Instant.now())); System.out.println(statement); statement.executeUpdate(); + ResultSet newIDRS = statement.getGeneratedKeys(); + newIDRS.first(); + Integer newID = newIDRS.getInt(1); connection.commit(); - return null; + return newID; } } diff --git a/Lambdas/Lists/List/src/ListGetter.java b/Lambdas/Lists/List/src/ListGetter.java index 3e4ff1e..e34366c 100644 --- a/Lambdas/Lists/List/src/ListGetter.java +++ b/Lambdas/Lists/List/src/ListGetter.java @@ -23,13 +23,14 @@ public class ListGetter implements CallHandler{ @Override public Object conductAction(Map bodyMap, HashMap queryMap, String cognitoID) throws SQLException { - Connection connection = connector.getConnection(); - Integer id = Integer.parseInt(queryMap.get("id")); - try { + try (Connection connection = connector.getConnection()) { + Integer id = Integer.parseInt(queryMap.get("id")); if (id == -1) { PreparedStatement getLists = connection.prepareStatement(GET_LISTS); getLists.setString(1, cognitoID); + System.out.println(getLists); ResultSet getListsResults = getLists.executeQuery(); + System.out.println(getListsResults); ArrayList listIds = new ArrayList<>(); while (getListsResults.next()) { listIds.add(getListsResults.getInt(1)); @@ -48,11 +49,10 @@ public class ListGetter implements CallHandler{ getListEntries.setInt(1, id); ResultSet getEntryResults = getListEntries.executeQuery(); while (getEntryResults.next()) { - retrievedList.addItemEntry(new ItemEntry(getEntryResults)); + retrievedList.addItemEntry(new ItemEntry(id, getEntryResults)); } + System.out.println(retrievedList); return retrievedList; - } finally { - connection.close(); } } } diff --git a/Lambdas/Lists/Item/src/ItemAdder.java b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java similarity index 87% rename from Lambdas/Lists/Item/src/ItemAdder.java rename to Lambdas/Lists/ListEntry/src/ListEntryAdder.java index c698a04..2145cd5 100644 --- a/Lambdas/Lists/Item/src/ItemAdder.java +++ b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java @@ -6,14 +6,14 @@ import java.time.ZoneOffset; import java.util.HashMap; import java.util.Map; -public class ItemAdder implements CallHandler { +public class ListEntryAdder implements CallHandler { private DBConnector connector; private String cognitoID; private final String ITEM_TO_LIST = "INSERT INTO ListProduct (productID, listID, quantity, addedDate, purchased) VALUES (?, ?, ?, ?, ?)"; - public ItemAdder(DBConnector connector, String cognitoID) { + public ListEntryAdder(DBConnector connector, String cognitoID) { this.connector = connector; this.cognitoID = cognitoID; } @@ -22,7 +22,7 @@ public class ItemAdder implements CallHandler { Connection connection = connector.getConnection(); try { PreparedStatement statement = connection.prepareStatement(ITEM_TO_LIST); - statement.setInt(1, (Integer) bodyMap.get("itemID")); + 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()); diff --git a/Lambdas/Lists/Item/src/ItemDELETE.java b/Lambdas/Lists/ListEntry/src/ListEntryDELETE.java similarity index 57% rename from Lambdas/Lists/Item/src/ItemDELETE.java rename to Lambdas/Lists/ListEntry/src/ListEntryDELETE.java index 7d0f1ee..ad3045d 100644 --- a/Lambdas/Lists/Item/src/ItemDELETE.java +++ b/Lambdas/Lists/ListEntry/src/ListEntryDELETE.java @@ -3,9 +3,9 @@ import com.amazonaws.services.lambda.runtime.RequestHandler; import java.util.Map; -public class ItemDELETE implements RequestHandler, Object> { +public class ListEntryDELETE implements RequestHandler, Object> { public Object handleRequest(Map inputMap, Context unfilled) { - return BasicHandler.handleRequest(inputMap, unfilled, ItemGetter.class); + return BasicHandler.handleRequest(inputMap, unfilled, ListEntryDeleter.class); } } \ No newline at end of file diff --git a/Lambdas/Lists/Item/src/ItemDeleter.java b/Lambdas/Lists/ListEntry/src/ListEntryDeleter.java similarity index 89% rename from Lambdas/Lists/Item/src/ItemDeleter.java rename to Lambdas/Lists/ListEntry/src/ListEntryDeleter.java index ad03a91..af074cd 100644 --- a/Lambdas/Lists/Item/src/ItemDeleter.java +++ b/Lambdas/Lists/ListEntry/src/ListEntryDeleter.java @@ -4,14 +4,14 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.Map; -public class ItemDeleter implements CallHandler { +public class ListEntryDeleter implements CallHandler { private DBConnector connector; private String cognitoID; private final String REMOVE_FROM_LIST = "DELETE FROM ListProduct WHERE (ProductID = ? AND ListID = ?);"; - public ItemDeleter(DBConnector connector, String cognitoID) { + public ListEntryDeleter(DBConnector connector, String cognitoID) { this.connector = connector; this.cognitoID = cognitoID; } diff --git a/Lambdas/Lists/Item/src/ItemPOST.java b/Lambdas/Lists/ListEntry/src/ListEntryPOST.java similarity index 57% rename from Lambdas/Lists/Item/src/ItemPOST.java rename to Lambdas/Lists/ListEntry/src/ListEntryPOST.java index 51d107f..828c43c 100644 --- a/Lambdas/Lists/Item/src/ItemPOST.java +++ b/Lambdas/Lists/ListEntry/src/ListEntryPOST.java @@ -3,9 +3,9 @@ import com.amazonaws.services.lambda.runtime.RequestHandler; import java.util.Map; -public class ItemPOST implements RequestHandler, Object> { +public class ListEntryPOST implements RequestHandler, Object> { public Object handleRequest(Map inputMap, Context unfilled) { - return BasicHandler.handleRequest(inputMap, unfilled, ItemAdder.class); + return BasicHandler.handleRequest(inputMap, unfilled, ListEntryAdder.class); } } diff --git a/Lambdas/Lists/src/main/java/BasicHandler.java b/Lambdas/Lists/src/main/java/BasicHandler.java index 2a7ec6e..8c3e1d3 100644 --- a/Lambdas/Lists/src/main/java/BasicHandler.java +++ b/Lambdas/Lists/src/main/java/BasicHandler.java @@ -24,7 +24,7 @@ public class BasicHandler { } } catch (IOException |SQLException|ClassNotFoundException e) { e.printStackTrace(); - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e.getLocalizedMessage()); } return null; } diff --git a/Listify/app/src/main/java/com/example/listify/AuthManager.java b/Listify/app/src/main/java/com/example/listify/AuthManager.java index 4e67ed3..030fb88 100644 --- a/Listify/app/src/main/java/com/example/listify/AuthManager.java +++ b/Listify/app/src/main/java/com/example/listify/AuthManager.java @@ -44,6 +44,13 @@ public class AuthManager { } public String getUserToken() { + if (authSession == null) { + try { + fetchAuthSession(); + } catch (AuthException e) { + e.printStackTrace(); + } + } return authSession.getUserPoolTokens().getValue().getIdToken(); } diff --git a/Listify/app/src/main/java/com/example/listify/Item.java b/Listify/app/src/main/java/com/example/listify/Item.java deleted file mode 100644 index f66f8ec..0000000 --- a/Listify/app/src/main/java/com/example/listify/Item.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.example.listify; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -public class Item { - Integer productID; - Integer chainID; - String upc; - String description; - BigDecimal price; - String imageURL; - String department; - LocalDateTime retrievedDate; - Integer fetchCounts; - - public Item(Integer productID, Integer chainID, String upc, String description, BigDecimal price, - String imageURL, String department, LocalDateTime retrievedDate, Integer fetchCounts) { - this.productID = productID; - this.chainID = chainID; - this.upc = upc; - this.description = description; - this.price = price; - this.imageURL = imageURL; - this.department = department; - this.retrievedDate = retrievedDate; - this.fetchCounts = fetchCounts; - } - - @Override - public String toString() { - return "Item{" + - "productID=" + productID + - ", chainID=" + chainID + - ", upc='" + upc + '\'' + - ", description='" + description + '\'' + - ", price=" + price + - ", imageURL='" + imageURL + '\'' + - ", department='" + department + '\'' + - ", retrievedDate=" + retrievedDate + - ", fetchCounts=" + fetchCounts + - '}'; - } -} diff --git a/Listify/app/src/main/java/com/example/listify/List.java b/Listify/app/src/main/java/com/example/listify/List.java deleted file mode 100644 index 3a828b1..0000000 --- a/Listify/app/src/main/java/com/example/listify/List.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.listify; - -public class List { - String name; - List(String name) { - this.name = name; - } -} 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 59c63d4..99ff02d 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -13,11 +13,18 @@ import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; import com.amplifyframework.auth.AuthException; +import com.example.listify.data.Item; +import com.example.listify.data.ListEntry; +import com.example.listify.data.List; import com.google.android.material.navigation.NavigationView; import org.json.JSONException; import java.io.IOException; +import java.time.Instant; +import java.time.ZoneOffset; +import java.util.Arrays; import java.util.Properties; +import java.util.Random; public class MainActivity extends AppCompatActivity { private AppBarConfiguration mAppBarConfiguration; @@ -29,51 +36,73 @@ public class MainActivity extends AppCompatActivity { //------------------------------Auth Testing---------------------------------------------// - AuthManager authManager = new AuthManager(); - try { - authManager.signIn("merzn@purdue.edu", "Password123"); - Log.i("Authentication", authManager.getAuthSession().toString()); - Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); - } catch (AuthException e) { - Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); + boolean testAuth = false; + + if (testAuth) { + + AuthManager authManager = new AuthManager(); try { - authManager.startSignUp("merzn@purdue.edu", "Password123"); - authManager.confirmSignUp("######"); - } catch (AuthException signUpError) { - Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); + authManager.signIn("merzn@purdue.edu", "Password123"); + Log.i("Authentication", authManager.getAuthSession().toString()); + Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); + } catch (AuthException e) { + Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); + try { + authManager.startSignUp("merzn@purdue.edu", "Password123"); + authManager.confirmSignUp("######"); + } catch (AuthException signUpError) { + Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); + } } } - //------------------------------------------------------------------------------------------// - + boolean testAPI = true; //----------------------------------API Testing---------------------------------------------// - Properties configs = new Properties(); - try { - configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); - } catch (IOException|JSONException e) { - e.printStackTrace(); + if (testAPI) { + AuthManager authManager = new AuthManager(); + try { + authManager.signIn("merzn@purdue.edu", "Password123"); + } catch (AuthException e) { + e.printStackTrace(); + } + Properties configs = new Properties(); + try { + configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); + } catch (IOException | JSONException e) { + e.printStackTrace(); + } + + Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey")); + //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().atZone(ZoneOffset.UTC).toLocalDateTime(),false); + SynchronousReceiver idReceiver = new SynchronousReceiver<>(); + try { + requestor.postObject(testList, idReceiver, idReceiver); + System.out.println(idReceiver.await()); + requestor.postObject(entry); + } catch (JSONException | IOException e) { + e.printStackTrace(); + } + + SynchronousReceiver itemReceiver = new SynchronousReceiver<>(); + requestor.getObject("1", Item.class, itemReceiver, itemReceiver); + SynchronousReceiver listReceiver = new SynchronousReceiver<>(); + requestor.getObject("39", List.class, listReceiver, listReceiver); + SynchronousReceiver listIdsReceiver = new SynchronousReceiver<>(); + requestor.getListOfIds(List.class, listIdsReceiver, listIdsReceiver); + try { + System.out.println(itemReceiver.await()); + System.out.println(listReceiver.await()); + System.out.println(Arrays.toString(listIdsReceiver.await())); + } catch (IOException receiverError) { + receiverError.printStackTrace(); + } } - - Requestor requestor = new Requestor(authManager,configs.getProperty("apiKey")); - List testList = new List("IAmATestList"); - try { - requestor.postObject(testList); - } catch (JSONException e) { - e.printStackTrace(); - } - - SynchronousReceiver receiver = new SynchronousReceiver(); - requestor.getObject("1", Item.class, receiver, receiver); - try { - System.out.println(receiver.await()); - } catch (IOException receiverError) { - receiverError.printStackTrace(); - } - - //------------------------------------------------------------------------------------------// diff --git a/Listify/app/src/main/java/com/example/listify/Requestor.java b/Listify/app/src/main/java/com/example/listify/Requestor.java index 2134ac8..5f34f98 100644 --- a/Listify/app/src/main/java/com/example/listify/Requestor.java +++ b/Listify/app/src/main/java/com/example/listify/Requestor.java @@ -29,7 +29,7 @@ public class Requestor { } public void getListOfIds(Class ofType, Receiver successHandler, RequestErrorHandler failureHandler) { - String getURL = DEV_BASEURL + "/" + ofType.getSimpleName() + "?list=-1"; + String getURL = DEV_BASEURL + "/" + ofType.getSimpleName() + "?id=-1"; Request postRequest = buildBaseRequest(getURL, "GET", null); launchCall(postRequest, successHandler, Integer[].class, failureHandler); } @@ -41,15 +41,22 @@ public class Requestor { } public void postObject(Object toPost) throws JSONException { - postObject(toPost, null); + postObject(toPost, (RequestErrorHandler) null); } public void postObject(Object toPost, RequestErrorHandler failureHandler) throws JSONException { - String postURL = DEV_BASEURL + "/" + toPost.getClass().getSimpleName(); - Request postRequest = buildBaseRequest(postURL, "POST", new Gson().toJson(toPost)); - launchCall(postRequest, null, null, failureHandler); + postObject(toPost, null, failureHandler); } + public void postObject(Object toPost, Receiver idReceiver) throws JSONException { + postObject(toPost, idReceiver, null); + } + + public void postObject(Object toPost, Receiver idReceiver, RequestErrorHandler failureHandler) throws JSONException { + String postURL = DEV_BASEURL + "/" + toPost.getClass().getSimpleName(); + Request postRequest = buildBaseRequest(postURL, "POST", new Gson().toJson(toPost)); + launchCall(postRequest, idReceiver, Integer.class, failureHandler); + } private void launchCall(Request toLaunch, Receiver receiver, Class classType, RequestErrorHandler failureHandler) { client.newCall(toLaunch).enqueue(new Callback() { diff --git a/Listify/app/src/main/java/com/example/listify/data/Item.java b/Listify/app/src/main/java/com/example/listify/data/Item.java new file mode 100644 index 0000000..07662b5 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/Item.java @@ -0,0 +1,116 @@ +package com.example.listify.data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +public class Item { + Integer productID; + Integer chainID; + String upc; + String description; + BigDecimal price; + String imageURL; + String department; + LocalDateTime retrievedDate; + Integer fetchCounts; + + public Item(Integer productID, Integer chainID, String upc, String description, BigDecimal price, + String imageURL, String department, LocalDateTime retrievedDate, Integer fetchCounts) { + this.productID = productID; + this.chainID = chainID; + this.upc = upc; + this.description = description; + this.price = price; + this.imageURL = imageURL; + this.department = department; + this.retrievedDate = retrievedDate; + this.fetchCounts = fetchCounts; + } + + @Override + public String toString() { + return "Item{" + + "productID=" + productID + + ", chainID=" + chainID + + ", upc='" + upc + '\'' + + ", description='" + description + '\'' + + ", price=" + price + + ", imageURL='" + imageURL + '\'' + + ", department='" + department + '\'' + + ", retrievedDate=" + (retrievedDate == null ? null : retrievedDate) + + ", fetchCounts=" + fetchCounts + + '}'; + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getChainID() { + return chainID; + } + + public void setChainID(Integer chainID) { + this.chainID = chainID; + } + + public String getUpc() { + return upc; + } + + public void setUpc(String upc) { + this.upc = upc; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public LocalDateTime getRetrievedDate() { + return retrievedDate; + } + + public void setRetrievedDate(LocalDateTime retrievedDate) { + this.retrievedDate = retrievedDate; + } + + public Integer getFetchCounts() { + return fetchCounts; + } + + public void setFetchCounts(Integer fetchCounts) { + this.fetchCounts = fetchCounts; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/List.java b/Listify/app/src/main/java/com/example/listify/data/List.java new file mode 100644 index 0000000..23d77ea --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/List.java @@ -0,0 +1,70 @@ +package com.example.listify.data; + +import java.util.Arrays; + +public class List { + Integer itemID; + String name; + String owner; + long lastUpdated; + final ListEntry[] entries; + + public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries) { + this.itemID = itemID; + this.name = name; + this.owner = owner; + this.lastUpdated = lastUpdated; + this.entries = entries; + } + + public List(Integer itemID, String name, String owner, long lastUpdated) { + this(itemID, name, owner, lastUpdated, null); + } + + @Override + public String toString() { + return "List{" + + "itemID=" + itemID + + ", name='" + name + '\'' + + ", owner='" + owner + '\'' + + ", lastUpdated=" + lastUpdated + + ", entries=" + Arrays.toString(entries) + + '}'; + } + + public Integer getItemID() { + return itemID; + } + + public void setItemID(Integer itemID) { + this.itemID = itemID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public long getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(long lastUpdated) { + this.lastUpdated = lastUpdated; + } + + public ListEntry[] getEntries() { + return entries; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/ListEntry.java b/Listify/app/src/main/java/com/example/listify/data/ListEntry.java new file mode 100644 index 0000000..404f649 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/ListEntry.java @@ -0,0 +1,70 @@ +package com.example.listify.data; + +import java.time.LocalDateTime; + +public class ListEntry { + Integer listID; + Integer productID; + Integer quantity; + LocalDateTime addedDate; + Boolean purchased; + + public ListEntry(Integer listID, Integer productID, Integer quantity, LocalDateTime addedDate, Boolean purchased) { + this.listID = listID; + this.productID = productID; + this.quantity = quantity; + this.addedDate = addedDate; + this.purchased = purchased; + } + + @Override + public String toString() { + return "ListEntry{" + + "listID=" + listID + + ", productID=" + productID + + ", quantity=" + quantity + + ", addedDate=" + addedDate + + ", purchased=" + purchased + + '}'; + } + + public Integer getListID() { + return listID; + } + + public void setListID(Integer listID) { + this.listID = listID; + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public LocalDateTime getAddedDate() { + return addedDate; + } + + public void setAddedDate(LocalDateTime addedDate) { + this.addedDate = addedDate; + } + + public Boolean getPurchased() { + return purchased; + } + + public void setPurchased(Boolean purchased) { + this.purchased = purchased; + } +} diff --git a/Tooling/EndpointSetup.sh b/Tooling/EndpointSetup.sh index 9b8940d..7d72d34 100644 --- a/Tooling/EndpointSetup.sh +++ b/Tooling/EndpointSetup.sh @@ -11,7 +11,7 @@ REL_SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") source ${REL_SCRIPT_DIR}/VarSetup.sh -RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${jarPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method} 2>${DEBUGFILE}) +RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${jarPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method} --memory-size 512 2>${DEBUGFILE}) if [[ $? -ne 0 ]]; then