- public void PutTest() {
-
- try {
- DcaeLocation loc = factory.genDcaeLocation( "central" );
- Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
- Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
- System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
- if ( resp.getStatus() != 409 ) {
- assertTrue( resp.getStatus() >= 200 && resp.getStatus() < 300 );
- }
- } catch (Exception e ) {
- }
-
- String h[] = {"host4", "host5", "host6" };
- MR_Cluster cluster = factory.genMR_Cluster( "central" );
- Entity<MR_Cluster> reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
- Response resp = target( "mr_clusters").request().post( reqEntity, Response.class );
-
- // first, add it
- System.out.println( "POST MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity( String.class ) );
- if( resp.getStatus() != 409 ) {
- assertTrue( resp.getStatus() >= 200 && resp.getStatus() < 300 );
- }
-
- // now change a field
-
- reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
-
- // update with incorrect key
- resp = target( "mr_clusters")
- .path( "invalidLocationNam" )
- .request()
- .put( reqEntity, Response.class );
- System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
- assertTrue( resp.getStatus() == 404 );
-
- // update with correct key
- resp = target( "mr_clusters")
- .path( cluster.getDcaeLocationName())
- .request()
- .put( reqEntity, Response.class );
- System.out.println( "PUT MR_Cluster resp=" + resp.getStatus() + " " + resp.readEntity(String.class));
- assertTrue( resp.getStatus() >= 200 && resp.getStatus() < 300 );
+ public void updateMrCluster_shouldReturnApiError_whenMrClusterWithGivenIdNotFound() {
+ //given
+ MR_Cluster mr_cluster = new MR_Cluster();
+ mr_cluster.setDcaeLocationName("central-cloud");
+ Entity<MR_Cluster> requestEntity = entity(mr_cluster, APPLICATION_JSON);
+
+ //when
+ Response resp = testContainer.target(MR_CLUSTERS_TARGET).path("notExistingMrCluster")
+ .request().put(requestEntity, Response.class);
+
+ //then
+ assertEquals(HttpStatus.NOT_FOUND_404, resp.getStatus());
+ assertTrue(resp.hasEntity());
+ ApiError errorObj = resp.readEntity(ApiError.class);
+ assertEquals("dcaeLocationName", errorObj.getFields());