當前位置: 首頁>>代碼示例>>Java>>正文


Java ConceptService.getConceptByName方法代碼示例

本文整理匯總了Java中org.openmrs.api.ConceptService.getConceptByName方法的典型用法代碼示例。如果您正苦於以下問題:Java ConceptService.getConceptByName方法的具體用法?Java ConceptService.getConceptByName怎麽用?Java ConceptService.getConceptByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openmrs.api.ConceptService的用法示例。


在下文中一共展示了ConceptService.getConceptByName方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldAddConceptWithOnlyNameSpecified

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * This test concept form being submitted with only one name supplied
 * 
 * @throws Exception
 */
@Test
public void shouldAddConceptWithOnlyNameSpecified() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", "some description");
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(1, actualNames.size());
	assertNull(actualConcept.getShortNameInLocale(britishEn));
	assertNotNull(actualConcept.getDescription(britishEn));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:38,代碼來源:ConceptFormControllerTest.java

示例2: shouldAddConceptWithNameAndShortNameSpecified

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * This tests a concept form being submitted with also a short name supplied
 * 
 * @throws Exception
 */
@Test
public void shouldAddConceptWithNameAndShortNameSpecified() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", "some description");
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(2, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertEquals(1, actualConcept.getShortNames().size());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:41,代碼來源:ConceptFormControllerTest.java

示例3: shouldAddConceptWithNameAndShortNameAndDescriptionSpecifiedToCodeConcepts

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Tests a concept form being submitted with name/shortname/description all filled in
 * 
 * @throws Exception
 */
@Test
public void shouldAddConceptWithNameAndShortNameAndDescriptionSpecifiedToCodeConcepts() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "4");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(2, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
	
	assertNotNull(actualConcept.getDescription(britishEn));
	assertEquals(EXPECTED_DESCRIPTION, actualConcept.getDescription(britishEn).getDescription());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:45,代碼來源:ConceptFormControllerTest.java

示例4: shouldAddConceptWithNameAndShortNameAndDescriptionSpecifiedToNumericConcepts

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Tests a concept form being submitted with a name and description for numeric type of concepts
 * 
 * @throws Exception
 */
@Test
public void shouldAddConceptWithNameAndShortNameAndDescriptionSpecifiedToNumericConcepts() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(2, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
	
	assertNotNull(actualConcept.getDescription(britishEn));
	assertEquals(EXPECTED_DESCRIPTION, actualConcept.getDescription(britishEn).getDescription());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:45,代碼來源:ConceptFormControllerTest.java

示例5: shouldUpdateConceptByAddingName

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test updating a concept by adding a name
 * 
 * @throws Exception
 */
@Test
public void shouldUpdateConceptByAddingName() throws Exception {
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept already exists
	Concept concept = cs.getConcept(3);
	assertNotNull(concept);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("conceptId", concept.getConceptId().toString());
	mockRequest.setParameter("namesByLocale[en_GB].name", "new name");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	updateSearchIndex();
	
	Concept actualConcept = cs.getConceptByName("new name");
	assertNotNull(actualConcept);
	assertEquals(concept.getConceptId(), actualConcept.getConceptId());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:34,代碼來源:ConceptFormControllerTest.java

示例6: shouldVoidShortName

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test removing short name by adding a blank short name
 *
 * @throws Exception
 */
@Test
public void shouldVoidShortName() throws Exception {
	final String CONCEPT_NAME = "default concept name";
	
	ConceptService cs = Context.getConceptService();
	
	final Concept concept = new Concept();
	concept.addName(new ConceptName(CONCEPT_NAME, britishEn));
	concept.setShortName(new ConceptName("shortname", britishEn));
	concept.addDescription(new ConceptDescription("some description", null));
	cs.saveConcept(concept);
	
	Concept actualConcept = cs.getConceptByName(CONCEPT_NAME);
	assertThat(actualConcept.getShortNameInLocale(britishEn), is(notNullValue()));
	assertThat(actualConcept.getShortNames().size(), greaterThan(0));
	assertThat(actualConcept.getNames().size(), is(2));
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("conceptId", concept.getConceptId().toString());
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", " ");
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	
	actualConcept = cs.getConceptByName(CONCEPT_NAME);
	assertThat(actualConcept.getShortNameInLocale(britishEn), is(nullValue()));
	assertThat(actualConcept.getShortNames().size(), is(0));
	assertThat(actualConcept.getNames().size(), is(1));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:42,代碼來源:ConceptFormControllerTest.java

示例7: onSubmit_shouldAddANewConceptMapWhenCreatingAConcept

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * @see ConceptFormController#onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
 */
@Test
@Verifies(value = "should add a new Concept map when creating a concept", method = "onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)")
public void onSubmit_shouldAddANewConceptMapWhenCreatingAConcept() throws Exception {
	ConceptService cs = Context.getConceptService();
	final String conceptName = "new concept";
	// make sure the concept doesn't already exist
	Concept newConcept = cs.getConceptByName(conceptName);
	assertNull(newConcept);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("namesByLocale[en_GB].name", conceptName);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", "some description");
	mockRequest.setParameter("concept.datatype", "1");
	mockRequest.setParameter("conceptMappings[0].conceptReferenceTerm", "1");
	mockRequest.setParameter("conceptMappings[0].conceptMapType", "3");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept createdConcept = cs.getConceptByName(conceptName);
	assertNotNull(createdConcept);
	Assert.assertEquals(1, createdConcept.getConceptMappings().size());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:34,代碼來源:ConceptFormControllerTest.java

示例8: shouldSaveConceptAttributeOnCreatingConcept

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * @verifies should add new concept attributes on creating concept
 * @throws Exception
 */
@Test
public void shouldSaveConceptAttributeOnCreatingConcept() throws Exception {
	executeDataSet(CONCEPT_ATTRIBUTES_XML);
	final String EXPECTED_PREFERRED_NAME = "concept with attribute";

	ConceptService cs = Context.getConceptService();

	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);

	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");

	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", "some description");
	mockRequest.setParameter("concept.datatype", "1");
	mockRequest.setParameter("attribute.1.new[0]", "2011-04-25");

	ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());

	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	final Collection<ConceptAttribute> attributes = actualConcept.getAttributes();
	assertEquals(1, attributes.size());
	final ConceptAttribute conceptAttribute = attributes.iterator().next();
	assertEquals("2011-04-25", conceptAttribute.getValueReference());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:37,代碼來源:ConceptFormControllerTest.java

示例9: doStartTag

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
public int doStartTag() throws JspException {
	ConceptService cs = Context.getConceptService();
	
	// Search for a concept by id
	if (conceptId != null) {
		c = cs.getConcept(conceptId);
	} else if (conceptName != null) {
		c = cs.getConceptByName(conceptName);
	}
	if (c == null) {
		if (conceptId != null && conceptId > 0) {
			log.warn("ConceptTag is unable to find a concept with conceptId '" + conceptId + "'");
		}
		if (conceptName != null) {
			log.warn("ConceptTag is unable to find a concept with conceptName '" + conceptName + "'");
		}
		return SKIP_BODY;
	}
	pageContext.setAttribute(var, c);
	log.debug("Found concept with id " + conceptId + ", set to variable: " + var);
	
	// If user specifies a locale in the tag, try to find a matching locale. Otherwise, use the user's default locale
	Locale loc = Context.getLocale();
	if (StringUtils.isNotEmpty(locale)) {
		Locale[] locales = Locale.getAvailableLocales();
		for (int i = 0; i < locales.length; i++) {
			if (locale.equals(locales[i].toString())) {
				loc = locales[i];
				break;
			}
		}
	}
	if (nameVar != null) {
		ConceptName cName = c.getName(loc);
		if (cName == null) {
			cName = c.getName();
		}
		pageContext.setAttribute(nameVar, cName);
		log.debug("Retrieved name " + cName.getName() + ", set to variable: " + nameVar);
	}
	
	if (shortestNameVar != null) {
		pageContext.setAttribute(shortestNameVar, c.getShortestName(loc, false));
	}
	
	if (numericVar != null) {
		pageContext.setAttribute(numericVar, cs.getConceptNumeric(conceptId));
	}
	
	// If the Concept is a Set, get members of that Set
	if (c.isSet() && setMemberVar != null) {
		pageContext.setAttribute(setMemberVar, Context.getConceptService().getConceptsByConceptSet(c));
	}
	
	// If the Concept is a Set, get members of that Set
	if (c.isSet() && setMemberVar != null) {
		pageContext.setAttribute(setMemberVar, Context.getConceptService().getConceptsByConceptSet(c));
	}
	
	return EVAL_BODY_BUFFERED;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:62,代碼來源:ConceptTag.java

示例10: shouldAddConceptWithAllNamingSpecified

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test adding a concept with a preferred name, short name, description and synonyms.
 * 
 * @throws Exception
 */
@Test
public void shouldAddConceptWithAllNamingSpecified() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	final String EXPECTED_SYNONYM_A = "phantom";
	final String EXPECTED_SYNONYM_B = "imaginary";
	final String EXPECTED_SYNONYM_C = "mock";
	
	AdministrationService as = Context.getAdministrationService();
	GlobalProperty gp = as.getGlobalPropertyObject(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST);
	gp.setPropertyValue("en_GB, en_US");
	as.saveGlobalProperty(gp);
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("synonymsByLocale[en_GB][0].name", EXPECTED_SYNONYM_A);
	mockRequest.setParameter("synonymsByLocale[en_GB][1].name", EXPECTED_SYNONYM_B);
	mockRequest.setParameter("synonymsByLocale[en_GB][2].name", EXPECTED_SYNONYM_C);
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(5, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
	
	assertNotNull(actualConcept.getDescription(britishEn));
	assertEquals(EXPECTED_DESCRIPTION, actualConcept.getDescription(britishEn).getDescription());
	
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:57,代碼來源:ConceptFormControllerTest.java

示例11: shouldUpdateConceptWithNameAlreadyInSynonymList

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test adding a concept with a preferred name, short name, description and synonyms.
 * 
 * @throws Exception
 */
@Test
public void shouldUpdateConceptWithNameAlreadyInSynonymList() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	final String EXPECTED_SYNONYM_A = "phantom";
	final String EXPECTED_SYNONYM_B = EXPECTED_PREFERRED_NAME;
	final String EXPECTED_SYNONYM_C = "mock";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("synonymsByLocale[en_GB][0].name", EXPECTED_SYNONYM_A);
	mockRequest.setParameter("synonymsByLocale[en_GB][1].name", EXPECTED_SYNONYM_B);
	mockRequest.setParameter("synonymsByLocale[en_GB][2].name", EXPECTED_SYNONYM_C);
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(4, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
	
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:49,代碼來源:ConceptFormControllerTest.java

示例12: shouldUpdateConceptWithShortNameAlreadyInSynonymList

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test adding a concept with a preferred name, short name, description and synonyms.
 * 
 * @throws Exception
 */
@Test
public void shouldUpdateConceptWithShortNameAlreadyInSynonymList() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	final String EXPECTED_SYNONYM_A = "phantom";
	final String EXPECTED_SYNONYM_B = EXPECTED_SHORT_NAME;
	final String EXPECTED_SYNONYM_C = "mock";
	
	ConceptService cs = Context.getConceptService();
	
	// make sure the concept doesn't already exist
	Concept conceptToAdd = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNull(conceptToAdd);
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("synonymsByLocale[en_GB][0].name", EXPECTED_SYNONYM_A);
	mockRequest.setParameter("synonymsByLocale[en_GB][1].name", EXPECTED_SYNONYM_B);
	mockRequest.setParameter("synonymsByLocale[en_GB][2].name", EXPECTED_SYNONYM_C);
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	Collection<ConceptName> actualNames = actualConcept.getNames();
	assertEquals(4, actualNames.size());
	assertEquals(EXPECTED_PREFERRED_NAME, actualConcept.getFullySpecifiedName(britishEn).getName());
	assertNotNull(actualConcept.getShortNameInLocale(britishEn));
	assertEquals(EXPECTED_SHORT_NAME, actualConcept.getShortNameInLocale(britishEn).getName());
	
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:49,代碼來源:ConceptFormControllerTest.java

示例13: shouldReplacePreviousDescription

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test adding a concept with a preferred name, short name, description and synonyms.
 * 
 * @throws Exception
 */
@Test
public void shouldReplacePreviousDescription() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String ORIGINAL_DESCRIPTION = "this is indescribable";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	final String EXPECTED_SYNONYM_A = "phantom";
	final String EXPECTED_SYNONYM_B = EXPECTED_SHORT_NAME;
	final String EXPECTED_SYNONYM_C = "mock";
	
	ConceptService cs = Context.getConceptService();
	
	// first, add the concept with an original description
	Concept conceptToUpdate = new Concept();
	conceptToUpdate.addName(new ConceptName("demo name", Context.getLocale()));
	ConceptDescription originalConceptDescription = new ConceptDescription();
	originalConceptDescription.setLocale(britishEn);
	originalConceptDescription.setDescription(ORIGINAL_DESCRIPTION);
	conceptToUpdate.addDescription(originalConceptDescription);
	cs.saveConcept(conceptToUpdate);
	
	// then submit changes through the controller
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("synonymsByLocale[en_GB][0].name", EXPECTED_SYNONYM_A);
	mockRequest.setParameter("synonymsByLocale[en_GB][1].name", EXPECTED_SYNONYM_B);
	mockRequest.setParameter("synonymsByLocale[en_GB][2].name", EXPECTED_SYNONYM_C);
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	
	assertNotNull(actualConcept.getDescription(britishEn));
	assertEquals(EXPECTED_DESCRIPTION, actualConcept.getDescription(britishEn).getDescription());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:53,代碼來源:ConceptFormControllerTest.java


注:本文中的org.openmrs.api.ConceptService.getConceptByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。