=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/controller/FacilityControllerTest.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/controller/FacilityControllerTest.java 2013-03-08 05:11:33 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/controller/FacilityControllerTest.java 2013-03-08 05:21:57 +0000 @@ -168,11 +168,37 @@ { MockHttpSession session = getSession( "ALL" ); - mvc.perform( put( "/v1/facilities/abc123" ).content( "{}" ).session( session ).contentType( MediaType.APPLICATION_JSON ) ) + mvc.perform( put( "/v1/facilities/INVALID_IDENTIFIER" ).content( "{}" ).session( session ).contentType( MediaType.APPLICATION_JSON ) ) .andExpect( status().isNotFound() ); } @Test + public void testPutInvalidJsonUid() throws Exception + { + OrganisationUnit organisationUnit = createOrganisationUnit( 'A' ); + manager.save( organisationUnit ); + + MockHttpSession session = getSession( "ALL" ); + + mvc.perform( put( "/v1/facilities/" + organisationUnit.getUid() ).content( "INVALID JSON" ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( status().isBadRequest() ); + } + + @Test + public void testPutInvalidJsonUuid() throws Exception + { + OrganisationUnit organisationUnit = createOrganisationUnit( 'A' ); + manager.save( organisationUnit ); + + MockHttpSession session = getSession( "ALL" ); + + mvc.perform( put( "/v1/facilities/" + organisationUnit.getUuid() ).content( "INVALID JSON" ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( status().isBadRequest() ); + } + + @Test public void testPutFacilityUid() throws Exception { OrganisationUnit organisationUnit = createOrganisationUnit( 'A' ); @@ -227,6 +253,7 @@ .session( session ).contentType( MediaType.APPLICATION_JSON ) ) .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) + .andExpect( jsonPath( "$.active" ).value( true ) ) .andExpect( status().isCreated() ); } @@ -265,6 +292,15 @@ .andExpect( status().isCreated() ); } + @Test + public void testPostInvalidJson() throws Exception + { + MockHttpSession session = getSession( "ALL" ); + + mvc.perform( post( "/v1/facilities" ).content( "INVALID JSON" ).session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( status().isBadRequest() ); + } + //--------------------------------------------------------------------------------------------- // Test DELETE //--------------------------------------------------------------------------------------------- @@ -274,7 +310,7 @@ { MockHttpSession session = getSession( "ALL" ); - mvc.perform( delete( "/v1/facilities/abc123" ).session( session ) ) + mvc.perform( delete( "/v1/facilities/INVALID_IDENTIFIER" ).session( session ) ) .andExpect( status().isNotFound() ); }