=== 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 04:56:18 +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:11:33 +0000 @@ -32,6 +32,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.web.FredSpringWebTest; import org.hisp.dhis.web.webapi.v1.domain.Facility; +import org.hisp.dhis.web.webapi.v1.utils.OrganisationUnitToFacilityConverter; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; @@ -171,6 +172,46 @@ .andExpect( status().isNotFound() ); } + @Test + public void testPutFacilityUid() throws Exception + { + OrganisationUnit organisationUnit = createOrganisationUnit( 'A' ); + manager.save( organisationUnit ); + + Facility facility = new OrganisationUnitToFacilityConverter().convert( organisationUnit ); + facility.setName( "FacilityB" ); + facility.setActive( false ); + + MockHttpSession session = getSession( "ALL" ); + + mvc.perform( put( "/v1/facilities/" + organisationUnit.getUid() ).content( objectMapper.writeValueAsString( facility ) ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( jsonPath( "$.name" ).value( "FacilityB" ) ) + .andExpect( jsonPath( "$.active" ).value( false ) ) + .andExpect( status().isOk() ); + } + + @Test + public void testPutFacilityUuid() throws Exception + { + OrganisationUnit organisationUnit = createOrganisationUnit( 'A' ); + manager.save( organisationUnit ); + + Facility facility = new OrganisationUnitToFacilityConverter().convert( organisationUnit ); + facility.setName( "FacilityB" ); + facility.setActive( false ); + + MockHttpSession session = getSession( "ALL" ); + + mvc.perform( put( "/v1/facilities/" + organisationUnit.getUuid() ).content( objectMapper.writeValueAsString( facility ) ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( jsonPath( "$.name" ).value( "FacilityB" ) ) + .andExpect( jsonPath( "$.active" ).value( false ) ) + .andExpect( status().isOk() ); + } + //--------------------------------------------------------------------------------------------- // Test POST //---------------------------------------------------------------------------------------------