Skip to content

Commit 3cbb88e

Browse files
iluwatar#297 Create unit tests for Gateway API pattern
1 parent 88c3b04 commit 3cbb88e

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.iluwatar.api.gateway;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class ApiGatewayTest {
8+
9+
/**
10+
* Tests getting the data for a desktop client
11+
*/
12+
@Test
13+
public void testGetProductDesktop() {
14+
ApiGateway apiGateway = new ApiGateway();
15+
DesktopProduct desktopProduct = apiGateway.getProductDesktop();
16+
17+
assertEquals("20", desktopProduct.getPrice());
18+
assertEquals("/product-image.png", desktopProduct.getImagePath());
19+
}
20+
21+
/**
22+
* Tests getting the data for a mobile client
23+
*/
24+
@Test
25+
public void testGetProductMobile() {
26+
ApiGateway apiGateway = new ApiGateway();
27+
MobileProduct mobileProduct = apiGateway.getProductMobile();
28+
29+
assertEquals("20", mobileProduct.getPrice());
30+
}
31+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar.api.gateway;
2+
3+
import org.junit.Test;
4+
5+
/**
6+
*
7+
* Application test
8+
*
9+
*/
10+
public class AppTest {
11+
12+
@Test
13+
public void test() throws Exception {
14+
String[] args = {};
15+
App.main(args);
16+
}
17+
}

0 commit comments

Comments
 (0)