String name = conceptMapType.getName(); if (!StringUtils.hasText(name)) { errors.rejectValue("name", "ConceptMapType.error.nameRequired",
/** * @see ConceptService#getConceptMapTypeByName(String) */ @Test public void getConceptMapTypeByName_shouldReturnAConceptMapTypeMatchingTheSpecifiedName() { Assert.assertEquals("same-as", Context.getConceptService().getConceptMapTypeByName("same-as").getName()); }
/** * @see ConceptService#getConceptMapTypeByUuid(String) */ @Test public void getConceptMapTypeByUuid_shouldReturnAConceptMapTypeMatchingTheSpecifiedUuid() { Assert.assertEquals("is-parent-to", Context.getConceptService().getConceptMapTypeByUuid( "0e7a8536-49d6-11e0-8fed-18a905e044dc").getName()); }
/** * @see ConceptService#getDefaultConceptMapType() */ @Test public void getDefaultConceptMapType_shouldReturnSameAsByDefault() { ConceptMapType conceptMapType = conceptService.getDefaultConceptMapType(); Assert.assertNotNull(conceptMapType); Assert.assertEquals("same-as", conceptMapType.getName()); }
/** * @see ConceptService#getConceptMapTypeByName(String) */ @Test public void getConceptMapTypeByName_shouldBeCaseInsensitive() { String name = "SAME-as"; ConceptMapType mt = Context.getConceptService().getConceptMapTypeByName(name); Assert.assertNotNull(mt); //sanity check in case the test dataset is edited Assert.assertNotSame(name, mt.getName()); Assert.assertEquals(2, mt.getId().intValue()); }
/** * @see ConceptService#getDefaultConceptMapType() */ @Test public void getDefaultConceptMapType_shouldReturnTypeAsSetInGp() { final String testName = "is a"; Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("concept.defaultConceptMapType", testName)); ConceptMapType conceptMapType = conceptService.getDefaultConceptMapType(); Assert.assertNotNull(conceptMapType); Assert.assertEquals(testName, conceptMapType.getName()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<ConceptMapType> doSearch(RequestContext context) { List<ConceptMapType> types = Context.getConceptService().getConceptMapTypes(context.getIncludeAll(), context.getIncludeAll()); for (Iterator<ConceptMapType> iterator = types.iterator(); iterator.hasNext();) { ConceptMapType type = iterator.next(); //find matches excluding retired ones if necessary if (!Pattern.compile(Pattern.quote(context.getParameter("q")), Pattern.CASE_INSENSITIVE).matcher(type.getName()) .find()) { iterator.remove(); } } return new NeedsPaging<ConceptMapType>(types, context); }
/** * @see ConceptService#saveConceptMapType(ConceptMapType) */ @Test public void saveConceptMapType_shouldUpdateAnExistingConceptMapType() { ConceptMapType mapType = Context.getConceptService().getConceptMapType(1); //sanity checks Assert.assertNull(mapType.getDateChanged()); Assert.assertNull(mapType.getChangedBy()); mapType.setName("random name"); mapType.setDescription("random description"); ConceptMapType editedMapType = Context.getConceptService().saveConceptMapType(mapType); Context.flushSession(); Assert.assertEquals("random name", editedMapType.getName()); Assert.assertEquals("random description", editedMapType.getDescription()); //date changed and changed by should have been updated Assert.assertNotNull(editedMapType.getDateChanged()); Assert.assertNotNull(editedMapType.getChangedBy()); }
@Test public void shouldEditingAConceptMapType() throws Exception { final String newName = "updated name"; SimpleObject conceptMapTypeType = new SimpleObject(); conceptMapTypeType.add("name", newName); String json = new ObjectMapper().writeValueAsString(conceptMapTypeType); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(newName, service.getConceptMapTypeByUuid(getUuid()).getName()); }
@Test public void shouldGetAConceptMapTypeByName() throws Exception { final String name = "related-to"; MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + name); SimpleObject result = deserialize(handle(req)); ConceptMapType conceptMapTypeType = service.getConceptMapTypeByName(name); assertEquals(conceptMapTypeType.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(conceptMapTypeType.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldGetAnConceptMapTypeByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); ConceptMapType conceptMapTypeType = service.getConceptMapTypeByUuid(getUuid()); assertEquals(conceptMapTypeType.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(conceptMapTypeType.getName(), PropertyUtils.getProperty(result, "name")); assertEquals(conceptMapTypeType.isHidden(), PropertyUtils.getProperty(result, "isHidden")); assertEquals(conceptMapTypeType.getDescription(), PropertyUtils.getProperty(result, "description")); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropEquals("name", getObject().getName()); assertPropEquals("description", getObject().getDescription()); assertPropEquals("isHidden", getObject().getIsHidden()); assertPropEquals("retired", getObject().isRetired()); }
@Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropEquals("name", getObject().getName()); assertPropEquals("description", getObject().getDescription()); assertPropEquals("isHidden", getObject().getIsHidden()); assertPropEquals("retired", getObject().isRetired()); assertPropPresent("auditInfo"); }