@Test public void testUpdate() { Sample r1 = new Sample("toto"); r1 = this.request("service-based").xmlPost(r1).resource(r1.getClass()); Sample r2 = new Sample(r1); r2.setName("titi"); r2 = this.request("service-based/" + r1.getId()).xmlPut(r2).resource(r2.getClass()); Assertions.assertThat(r1).isNotEqualTo(r2); Assertions.assertThat(r1.getName()).contains("toto"); Assertions.assertThat(r2.getName()).contains("titi"); }
@Test public void testFindResource() { Sample r = new Sample("toto"); r = (Sample) this.request("service-based").xmlPost(r).resource(r.getClass()); Response response = this.request("service-based/" + r.getId()).get(); Assertions.assertThat(response.getStatus()).isEqualTo(Http.OK); }
@Test public void testCreateResource() { Sample r = new Sample("toto"); Response response = this.request("service-based").xmlPost(r); r = (Sample) response.resource(r.getClass()); Assertions.assertThat(r).isNotNull(); Assertions.assertThat(r.getName()).isEqualTo("toto"); }
@Test(expectedExceptions = {NotFoundClientException.class}) public void testDeleteResource() { Sample r = new Sample("toto"); r = this.request("service-based").xmlPost(r).resource(r.getClass()); Assertions.assertThat(r).isNotNull(); Response response = this.request("service-based/" + r.getId()).delete(); Assertions.assertThat(response.getStatus()).isEqualTo(Http.NO_CONTENT); this.request("service-based/" + r.getId()).get(); }