@Test public void findallTest() { setUpUserToProducts(); String xmlStr = userToProductClient.findAll(); List<UserToProductXml> lOfUserToProductXml = getLOfUserToProductMsgXml(xmlStr); assertEquals("userId should be ", 9, lOfUserToProductXml.size()); }
@Test public void countTest() { setUpUserToProducts(); String count = userToProductClient.getCount(); System.out.println(count); assertEquals("count failed Incorrect number of rows ", "9", count); }
@Test public void findTestByUserId() { setUpUserToProducts(); String xmlStr = userToProductClient.find("Braffa", " ", " "); List<UserToProductXml> lOfUserToProductXml = getLOfUserToProductMsgXml(xmlStr); assertEquals("userId should be ", 5, lOfUserToProductXml.size()); UserToProductXml UserToProductXml = lOfUserToProductXml.get(0); System.out.println(UserToProductXml.toString()); }
@Test public void deleteTest() { setUpUserToProducts(); String response = userToProductClient.delete("Braffa", "978098056856", "0"); System.out.println(response); assertEquals( "DELETE http://localhost:8080/sellemws/rest/usertoproduct/delete/Braffa/978098056856/0 returned a response status of 200 OK", response.toString()); }
@Test public void findTest() { setUpUserToProducts(); String xmlStr = userToProductClient.find("Braffa", "978098056856", "0"); List<UserToProductXml> lOfUserToProductXml = getLOfUserToProductMsgXml(xmlStr); assertEquals("One row should be returned ", 1, lOfUserToProductXml.size()); UserToProductXml UserToProductXml = lOfUserToProductXml.get(0); System.out.println(UserToProductXml.toString()); assertEquals("index should be 5 ", 5, UserToProductXml.getId()); assertEquals("userId should be ", "Braffa", UserToProductXml.getUserId()); assertEquals("productId should be ", "978098056856", UserToProductXml.getProductId()); assertEquals("productIndex should be ", "0", UserToProductXml.getProductIndex()); }
@Test public void createTest() { UserToProductXml userToProduct = new UserToProductXml.UserToProductBuilder() .id(5) .userId("Braffa") .productId("978098056856") .productIndex("0") .build(); UserToProductMsgXml UserToProductMsgXml = new UserToProductMsgXml(userToProduct); ClientResponse response = userToProductClient.create(UserToProductMsgXml); System.out.println(response); assertEquals( "create failed ", "POST http://localhost:8080/sellemws/rest/usertoproduct/create returned a response status of 200 OK", response.toString()); }
@Test public void findTestByProductId() { setUpUserToProducts(); String xmlStr = userToProductClient.find(" ", "9780789724410", " "); List<UserToProductXml> lOfUserToProductXml = getLOfUserToProductMsgXml(xmlStr); assertEquals("One row should be returned ", 2, lOfUserToProductXml.size()); UserToProductXml UserToProductXml = lOfUserToProductXml.get(0); System.out.println(UserToProductXml.toString()); assertEquals("index should be 2 ", 2, UserToProductXml.getId()); assertEquals("userId should be ", "georgie", UserToProductXml.getUserId()); assertEquals("productId should be ", "9780789724410", UserToProductXml.getProductId()); assertEquals("productIndex should be ", "0", UserToProductXml.getProductIndex()); UserToProductXml = lOfUserToProductXml.get(1); System.out.println(UserToProductXml.toString()); assertEquals("index should be 3 ", 3, UserToProductXml.getId()); assertEquals("userId should be ", "Braffa", UserToProductXml.getUserId()); assertEquals("productId should be ", "9780789724410", UserToProductXml.getProductId()); assertEquals("productIndex should be ", "0", UserToProductXml.getProductIndex()); }