=== 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-07 15:41:40 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/controller/FacilityControllerTest.java 2013-03-07 15:50:24 +0000 @@ -191,4 +191,24 @@ .andExpect( jsonPath( "$.active" ).value( false ) ) .andExpect( status().isCreated() ); } + + @Test + public void testPostNameDuplicate() throws Exception + { + MockHttpSession session = getSession( "ALL" ); + + Facility facility = new Facility( "FacilityA" ); + + mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) + .andExpect( status().isCreated() ); + + mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) + .session( session ).contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) + .andExpect( status().isCreated() ); + } }