struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts-examples] 02/02: Reformats code
Date Wed, 21 Feb 2018 10:19:23 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts-examples.git

commit 6a22bb1af4bc17e82db4a4424735566853dbc226
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Wed Feb 21 11:17:12 2018 +0100

    Reformats code
---
 .../struts/actions/data/OrderControllerTest.java   | 147 +++++++++++----------
 1 file changed, 76 insertions(+), 71 deletions(-)

diff --git a/rest-angular/src/test/java/org/apache/examples/struts/actions/data/OrderControllerTest.java
b/rest-angular/src/test/java/org/apache/examples/struts/actions/data/OrderControllerTest.java
index 38677f6..76eec4d 100644
--- a/rest-angular/src/test/java/org/apache/examples/struts/actions/data/OrderControllerTest.java
+++ b/rest-angular/src/test/java/org/apache/examples/struts/actions/data/OrderControllerTest.java
@@ -11,45 +11,50 @@ import org.springframework.mock.web.MockHttpServletResponse;
 
 import java.util.List;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
 import static org.junit.Assert.assertThat;
 
 public class OrderControllerTest extends StrutsRestTestCase<OrderController> {
 
-	@Before
-	public void init() throws Exception {
-		super.setUp();
-	}
-
-	@Test
-	public void testIndex() throws Exception {
-		ActionProxy proxy = getActionProxy("GET", "/data/order.json");
-		proxy.execute();
-		OrderController orderController = (OrderController) proxy.getAction();
-
-		Object model = orderController.getModel();
-		assertThat(model, notNullValue());
-		assertThat(model, is(instanceOf(List.class)));
-
-		List<Order> orders = (List<Order>) model;
-		assertThat("List contains 3 orders", orders.size(), is(greaterThanOrEqualTo(3)));
-	}
-
-	@Test
-	public void testShow() throws Exception {
-		ActionProxy proxy = getActionProxy("GET", "/data/order/3.json");
-		OrderController orderController = (OrderController) proxy.getAction();
-		orderController.setId("3");
-		proxy.execute();
-
-		Object model = orderController.getModel();
-		assertThat(model, notNullValue());
-		assertThat(model, is(instanceOf(Order.class)));
-
-		Order order = (Order) model;
-		assertThat(order.getClientName(), is(equalTo("Bob")));
-		assertThat(order.getAmount(), is(equalTo(33)));
-	}
+    @Before
+    public void init() throws Exception {
+        super.setUp();
+    }
+
+    @Test
+    public void testIndex() throws Exception {
+        ActionProxy proxy = getActionProxy("GET", "/data/order.json");
+        proxy.execute();
+        OrderController orderController = (OrderController) proxy.getAction();
+
+        Object model = orderController.getModel();
+        assertThat(model, notNullValue());
+        assertThat(model, is(instanceOf(List.class)));
+
+        List<Order> orders = (List<Order>) model;
+        assertThat("List contains 3 orders", orders.size(), is(greaterThanOrEqualTo(3)));
+    }
+
+    @Test
+    public void testShow() throws Exception {
+        ActionProxy proxy = getActionProxy("GET", "/data/order/3.json");
+        OrderController orderController = (OrderController) proxy.getAction();
+        orderController.setId("3");
+        proxy.execute();
+
+        Object model = orderController.getModel();
+        assertThat(model, notNullValue());
+        assertThat(model, is(instanceOf(Order.class)));
+
+        Order order = (Order) model;
+        assertThat(order.getClientName(), is(equalTo("Bob")));
+        assertThat(order.getAmount(), is(equalTo(33)));
+    }
 
     @Test
     public void testShowResult() throws Exception {
@@ -71,40 +76,40 @@ public class OrderControllerTest extends StrutsRestTestCase<OrderController>
{
         assertThat(ServletActionContext.getResponse().getStatus(), is(equalTo(400)));
     }
 
-	@Test
-	public void testValidation() throws Exception {
-		request.setParameter("clientName", "");
-		request.setParameter("amount", "1");
-		request.setParameter("request_locale", "en");
-		ActionProxy proxy = getActionProxy("POST", "/data/order.json");
-		OrderController orderController = (OrderController) proxy.getAction();
-
-		proxy.execute();
-
-		assertThat(ServletActionContext.getResponse().getStatus(), is(equalTo(406)));
-		assertThat(orderController.hasFieldErrors(), is(true));
-		assertThat(orderController.getFieldErrors().size(), is(2));
-		assertThat(orderController.getFieldErrors().get("amount").get(0), is(equalTo("Order amount
needs to be between 10 and 666")));
-		assertThat(orderController.getFieldErrors().get("clientName").get(0), is(equalTo("Client
name can not be blank")));
-	}
-
-	@Test
-	public void testCreate() throws Exception {
-		request.setParameter("clientName", "Grace Hopper");
-		request.setParameter("amount", "85");
-		ActionProxy proxy = getActionProxy("POST", "/data/order.json");
-		OrderController orderController = (OrderController) proxy.getAction();
-
-		proxy.execute();
-
-		assertThat(orderController.hasFieldErrors(), is(false));
-
-		Object model = orderController.getModel();
-		assertThat(model, notNullValue());
-		assertThat(model, is(instanceOf(Order.class)));
-
-		Order order = (Order) model;
-		assertThat(order.getClientName(), is(equalTo("Grace Hopper")));
-		assertThat(order.getAmount(), is(equalTo(85)));
-	}
+    @Test
+    public void testValidation() throws Exception {
+        request.setParameter("clientName", "");
+        request.setParameter("amount", "1");
+        request.setParameter("request_locale", "en");
+        ActionProxy proxy = getActionProxy("POST", "/data/order.json");
+        OrderController orderController = (OrderController) proxy.getAction();
+
+        proxy.execute();
+
+        assertThat(ServletActionContext.getResponse().getStatus(), is(equalTo(406)));
+        assertThat(orderController.hasFieldErrors(), is(true));
+        assertThat(orderController.getFieldErrors().size(), is(2));
+        assertThat(orderController.getFieldErrors().get("amount").get(0), is(equalTo("Order
amount needs to be between 10 and 666")));
+        assertThat(orderController.getFieldErrors().get("clientName").get(0), is(equalTo("Client
name can not be blank")));
+    }
+
+    @Test
+    public void testCreate() throws Exception {
+        request.setParameter("clientName", "Grace Hopper");
+        request.setParameter("amount", "85");
+        ActionProxy proxy = getActionProxy("POST", "/data/order.json");
+        OrderController orderController = (OrderController) proxy.getAction();
+
+        proxy.execute();
+
+        assertThat(orderController.hasFieldErrors(), is(false));
+
+        Object model = orderController.getModel();
+        assertThat(model, notNullValue());
+        assertThat(model, is(instanceOf(Order.class)));
+
+        Order order = (Order) model;
+        assertThat(order.getClientName(), is(equalTo("Grace Hopper")));
+        assertThat(order.getAmount(), is(equalTo(85)));
+    }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
lukaszlenart@apache.org.

Mime
View raw message