From 3cbb88e09cd145f3e04b0a227982e158e1b02254 Mon Sep 17 00:00:00 2001 From: tmcconville Date: Sun, 7 Feb 2016 17:05:45 -0600 Subject: [PATCH] #297 Create unit tests for Gateway API pattern --- .../iluwatar/api/gateway/ApiGatewayTest.java | 31 +++++++++++++++++++ .../com/iluwatar/api/gateway/AppTest.java | 17 ++++++++++ 2 files changed, 48 insertions(+) create mode 100644 api-gateway/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java create mode 100644 api-gateway/src/test/java/com/iluwatar/api/gateway/AppTest.java diff --git a/api-gateway/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java b/api-gateway/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java new file mode 100644 index 000000000..00abdacb5 --- /dev/null +++ b/api-gateway/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java @@ -0,0 +1,31 @@ +package com.iluwatar.api.gateway; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ApiGatewayTest { + + /** + * Tests getting the data for a desktop client + */ + @Test + public void testGetProductDesktop() { + ApiGateway apiGateway = new ApiGateway(); + DesktopProduct desktopProduct = apiGateway.getProductDesktop(); + + assertEquals("20", desktopProduct.getPrice()); + assertEquals("/product-image.png", desktopProduct.getImagePath()); + } + + /** + * Tests getting the data for a mobile client + */ + @Test + public void testGetProductMobile() { + ApiGateway apiGateway = new ApiGateway(); + MobileProduct mobileProduct = apiGateway.getProductMobile(); + + assertEquals("20", mobileProduct.getPrice()); + } +} diff --git a/api-gateway/src/test/java/com/iluwatar/api/gateway/AppTest.java b/api-gateway/src/test/java/com/iluwatar/api/gateway/AppTest.java new file mode 100644 index 000000000..706f34b71 --- /dev/null +++ b/api-gateway/src/test/java/com/iluwatar/api/gateway/AppTest.java @@ -0,0 +1,17 @@ +package com.iluwatar.api.gateway; + +import org.junit.Test; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() throws Exception { + String[] args = {}; + App.main(args); + } +}