@Test public void addPlantillaWithoutNombre() { Plantilla plantilla = preparaPlantilla(); plantilla.setNombre(null); ClientResponse response = resource.type("application/json").post(ClientResponse.class, plantilla); Assert.assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); ResultatOperacio resultatOperacio = response.getEntity(ResultatOperacio.class); Assert.assertEquals( CampoRequeridoException.REQUIRED_FIELD + "Nombre", resultatOperacio.getDescripcio()); }
@Test @Ignore public void updatePlantillaAndRemoveNombre() { Plantilla plantilla = preparaPlantilla(); ClientResponse response = resource.type("application/json").post(ClientResponse.class, plantilla); Assert.assertEquals(Status.CREATED.getStatusCode(), response.getStatus()); RestResponse restResponse = response.getEntity(new GenericType<RestResponse>() {}); String id = getFieldFromRestResponse(restResponse, "id"); Assert.assertNotNull(id); plantilla.setNombre(""); response = resource.path(id).type("application/json").put(ClientResponse.class, plantilla); Assert.assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); ResultatOperacio parResponseMessage = response.getEntity(ResultatOperacio.class); Assert.assertEquals( CampoRequeridoException.REQUIRED_FIELD + "Nombre", parResponseMessage.getDescripcio()); }
@Test @Ignore public void updatePlantilla() { Plantilla plantilla = preparaPlantilla(); ClientResponse response = resource.type("application/json").post(ClientResponse.class, plantilla); Assert.assertEquals(Status.CREATED.getStatusCode(), response.getStatus()); RestResponse restResponse = response.getEntity(new GenericType<RestResponse>() {}); String id = getFieldFromRestResponse(restResponse, "id"); Assert.assertNotNull(id); plantilla.setNombre("Prueba2"); response = resource .path(String.valueOf(plantilla.getId())) .type("application/json") .put(ClientResponse.class, plantilla); Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus()); restResponse = response.getEntity(new GenericType<RestResponse>() {}); Assert.assertEquals(plantilla.getNombre(), getFieldFromRestResponse(restResponse, "nombre")); }