dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21335
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10061: FRED-API: more tests for PUT
------------------------------------------------------------
revno: 10061
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-08 08:11:33 +0300
message:
FRED-API: more tests for PUT
modified:
dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/controller/FacilityControllerTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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
//---------------------------------------------------------------------------------------------