@Test public void test_creating_cchat_during_customer_signup() { Client client = JerseyClientBuilder.createClient(); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("*****@*****.**", "password"); client.register(feature); CChat cchat = new CChat("awais-zara"); List<CChat> cchats = new ArrayList<CChat>(); cchats.add(cchat); Customer customer = new Customer(); customer.setUsername("*****@*****.**"); customer.setPassword("password"); customer.setCchat(cchats); Customer customerPersisted = client .target(String.format(REST_PRODUCT_SERVICE_URL, RULE.getLocalPort())) .path(new StringBuilder("/customer").append("/signup").toString()) .request(MediaType.APPLICATION_JSON) .post(Entity.json(customer), Customer.class); assertThat(customerPersisted.getId()).isNotNull(); assertThat(customerPersisted.getCchat().get(0).getId()).isNotNull(); assertThat(customerPersisted.getCchat().get(0).getUniqueName()) .isEqualToIgnoringCase("awais-zara"); }
@Test public void test_customer_update_cchat_list() { Client client = JerseyClientBuilder.createClient(); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("*****@*****.**", "password"); client.register(feature); CChat cchat1 = new CChat("Usman-Safina-1"); CChat cchat2 = new CChat("Usman-Amjad-1"); CChat cchat3 = new CChat("Usman-Talha-1"); List<CChat> cchats = new ArrayList<CChat>(); cchats.add(cchat1); cchats.add(cchat2); cchats.add(cchat3); Customer customer = new Customer(); customer.setUsername("*****@*****.**"); customer.setPassword("password"); customer.setCchat(cchats); Customer customerPersisted = client .target(String.format(REST_PRODUCT_SERVICE_URL, RULE.getLocalPort())) .path(new StringBuilder("/customer").append("/signup").toString()) .request(MediaType.APPLICATION_JSON) .post(Entity.json(customer), Customer.class); assertThat(customerPersisted.getId()).isNotNull(); CChat cchat4 = new CChat("Usman-Safina-2"); CChat cchatPersisted = client .target(String.format(REST_PRODUCT_SERVICE_URL, RULE.getLocalPort())) .path( new StringBuilder("/customer/") .append(customerPersisted.getId()) .append("/cchat") .toString()) .request(MediaType.APPLICATION_JSON) .post(Entity.json(cchat4), CChat.class); assertThat(cchatPersisted.getId()).isNotNull(); }
@Test public void test_customer_creating_multiple_chat() { Client client = JerseyClientBuilder.createClient(); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("*****@*****.**", "password"); client.register(feature); CChat cchat1 = new CChat("Talha-Amjad"); CChat cchat2 = new CChat("Talha-Talha"); CChat cchat3 = new CChat("Talha-Zunabia"); List<CChat> cchats = new ArrayList<CChat>(); cchats.add(cchat1); cchats.add(cchat2); cchats.add(cchat3); Customer customer = new Customer(); customer.setUsername("*****@*****.**"); customer.setPassword("password"); customer.setCchat(cchats); Customer customerPersisted = client .target(String.format(REST_PRODUCT_SERVICE_URL, RULE.getLocalPort())) .path(new StringBuilder("/customer").append("/signup").toString()) .request(MediaType.APPLICATION_JSON) .post(Entity.json(customer), Customer.class); assertThat(customerPersisted.getId()).isNotNull(); List<CChat> cchatsPersisted = customerPersisted.getCchat(); assertThat(cchatsPersisted.get(0).getId()).isNotNull(); assertThat(cchatsPersisted.get(1).getId()).isNotNull(); assertThat(cchatsPersisted.get(2).getId()).isNotNull(); for (CChat cchat : cchatsPersisted) { cchats.contains(cchat.getUniqueName()); } }