@Override protected LocationAttributeType getExistingObject() { return locationService.getLocationAttributeType(EXISTING_ID); } }
@Override protected LocationAttributeType getObjectById(Integer id) { return Context.getLocationService().getLocationAttributeType(id); }
/** * @see LocationService#getLocationAttributeType(Integer) */ @Test public void getLocationAttributeType_shouldReturnNullIfNoLocationAttributeTypeExistsWithTheGivenId() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertNull(Context.getLocationService().getLocationAttributeType(999)); }
/** * @see LocationService#saveLocationAttributeType(LocationAttributeType) */ @Test public void saveLocationAttributeType_shouldEditAnExistingLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationService service = Context.getLocationService(); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); LocationAttributeType lat = service.getLocationAttributeType(1); lat.setName("A new name"); service.saveLocationAttributeType(lat); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); Assert.assertEquals("A new name", service.getLocationAttributeType(1).getName()); }
/** * @see LocationService#getLocationAttributeType(Integer) */ @Test public void getLocationAttributeType_shouldReturnTheLocationAttributeTypeWithTheGivenId() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals("Audit Date", Context.getLocationService().getLocationAttributeType(1).getName()); }
/** * @see LocationService#purgeLocationAttributeType(LocationAttributeType) */ @Test public void purgeLocationAttributeType_shouldCompletelyRemoveALocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size()); Context.getLocationService().purgeLocationAttributeType(Context.getLocationService().getLocationAttributeType(2)); Assert.assertEquals(1, Context.getLocationService().getAllLocationAttributeTypes().size()); }
/** * @see LocationService#retireLocationAttributeType(LocationAttributeType,String) */ @Test public void retireLocationAttributeType_shouldRetireALocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationAttributeType vat = Context.getLocationService().getLocationAttributeType(1); Assert.assertFalse(vat.getRetired()); Assert.assertNull(vat.getRetiredBy()); Assert.assertNull(vat.getDateRetired()); Assert.assertNull(vat.getRetireReason()); Context.getLocationService().retireLocationAttributeType(vat, "for testing"); vat = Context.getLocationService().getLocationAttributeType(1); Assert.assertTrue(vat.getRetired()); Assert.assertNotNull(vat.getRetiredBy()); Assert.assertNotNull(vat.getDateRetired()); Assert.assertEquals("for testing", vat.getRetireReason()); }
/** * @see LocationService#unretireLocationAttributeType(LocationAttributeType) */ @Test public void unretireLocationAttributeType_shouldUnretireARetiredLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationService service = Context.getLocationService(); LocationAttributeType lat = service.getLocationAttributeType(2); Assert.assertTrue(lat.getRetired()); Assert.assertNotNull(lat.getDateRetired()); Assert.assertNotNull(lat.getRetiredBy()); Assert.assertNotNull(lat.getRetireReason()); service.unretireLocationAttributeType(lat); Assert.assertFalse(lat.getRetired()); Assert.assertNull(lat.getDateRetired()); Assert.assertNull(lat.getRetiredBy()); Assert.assertNull(lat.getRetireReason()); }
/** * @see LocationAttributeTypeController#updateLocationAttributeType(LocationAttributeType,SimpleObject,WebRequest) * @verifies change a property on a location */ @Test public void updateLocationAttributeType_shouldChangeAPropertyOnALocationAttributeType() throws Exception { String json = "{\"description\":\"Updated description\"}"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); Assert.assertEquals("Updated description", Context.getLocationService().getLocationAttributeType(1).getDescription()); }
/** * @see LocationAttributeTypeController#retireLocationAttributeType(LocationAttributeType,String,WebRequest) * @verifies void a location attribute type */ @Test public void retireLocationAttributeType_shouldRetireALocationAttributeType() throws Exception { LocationAttributeType locationAttributeType = Context.getLocationService().getLocationAttributeType(1); Assert.assertFalse(locationAttributeType.isRetired()); MockHttpServletRequest request = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); request.addParameter("reason", "test"); handle(request); locationAttributeType = Context.getLocationService().getLocationAttributeType(1); Assert.assertTrue(locationAttributeType.isRetired()); Assert.assertEquals("test", locationAttributeType.getRetireReason()); }