本文整理了Java中org.openmrs.Obs.setFormField()
方法的一些代码示例,展示了Obs.setFormField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.setFormField()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:setFormField
[英]Sets the namespace and path of the form field that was used to capture the obs details in the form.
Note: Namespace and formFieldPath together must not exceed 254 characters in length, form applications can subtract the length of their namespace from 254 to determine the maximum length they can use for a form field path.
[中]设置用于捕获表单中obs详细信息的表单字段的命名空间和路径。
注意:名称空间和formFieldPath的长度不能超过254个字符,表单应用程序可以从254中减去名称空间的长度,以确定可用于表单字段路径的最大长度。
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test
public void setFormField_shouldSetTheUnderlyingFormNamespaceAndPathInTheCorrectPattern() throws Exception {
final String ns = "my ns";
final String path = "my path";
Obs obs = new Obs();
obs.setFormField(ns, path);
java.lang.reflect.Field formNamespaceAndPathProperty = Obs.class.getDeclaredField("formNamespaceAndPath");
formNamespaceAndPathProperty.setAccessible(true);
Assert.assertEquals(ns + FORM_NAMESPACE_PATH_SEPARATOR + path, formNamespaceAndPathProperty.get(obs));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test(expected = APIException.class)
public void setFormField_shouldRejectANamepaceAndPathCombinationLongerThanTheMaxLength() throws Exception {
StringBuilder nsBuffer = new StringBuilder(125);
for (int i = 0; i < 125; i++) {
nsBuffer.append("n");
}
for (int i = 0; i < 130; i++) {
nsBuffer.append("p");
}
final String ns = nsBuffer.toString();
final String path = "";
Obs obs = new Obs();
obs.setFormField(ns, path);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test(expected = APIException.class)
public void setFormField_shouldRejectANamepaceContainingTheSeparator() throws Exception {
final String ns = "my ns" + FORM_NAMESPACE_PATH_SEPARATOR;
Obs obs = new Obs();
obs.setFormField(ns, "");
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test(expected = APIException.class)
public void setFormField_shouldRejectAPathContainingTheSeparator() throws Exception {
final String path = FORM_NAMESPACE_PATH_SEPARATOR + "my path";
Obs obs = new Obs();
obs.setFormField("", path);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldNamespace()
*/
@Test
public void getFormFieldNamespace_shouldReturnTheCorrectNamespaceForAFormFieldWithAPath() throws Exception {
final String ns = "my ns";
final String path = "my path";
Obs obs = new Obs();
obs.setFormField(ns, path);
Assert.assertEquals(ns, obs.getFormFieldNamespace());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldPath()
*/
@Test
public void getFormFieldPath_shouldReturnNullIfThePathIsNotSpecified() throws Exception {
Obs obs = new Obs();
obs.setFormField("my ns", "");
Assert.assertNull(obs.getFormFieldPath());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldPath()
*/
@Test
public void getFormFieldPath_shouldReturnTheCorrectPathForAFormFieldWithANamespace() throws Exception {
final String ns = "my ns";
final String path = "my path";
Obs obs = new Obs();
obs.setFormField(ns, path);
Assert.assertEquals(path, obs.getFormFieldPath());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldPath()
*/
@Test
public void getFormFieldPath_shouldReturnThePathForAFormFieldThatHasNoNamespace() throws Exception {
final String path = "my path";
Obs obs = new Obs();
obs.setFormField("", path);
Assert.assertEquals(path, obs.getFormFieldPath());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldNamespace()
*/
@Test
public void getFormFieldNamespace_shouldReturnNullIfTheNamespaceIsNotSpecified() throws Exception {
Obs obs = new Obs();
obs.setFormField("", "my path");
Assert.assertNull(obs.getFormFieldNamespace());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getFormFieldNamespace()
*/
@Test
public void getFormFieldNamespace_shouldReturnTheNamespaceForAFormFieldThatHasNoPath() throws Exception {
final String ns = "my ns";
Obs obs = new Obs();
obs.setFormField(ns, null);
Assert.assertEquals(ns, obs.getFormFieldNamespace());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test
public void setFormField_shouldNotMarkTheObsAsDirtyWhenTheValueHasNotBeenChanged() throws Exception {
Obs obs = createObs(3);
obs.setFormField(obs.getFormFieldNamespace(), obs.getFormFieldPath());
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test
public void setFormField_shouldMarkTheObsAsDirtyWhenTheValueIsChangedFromANonNullToANullValue() throws Exception {
Obs obs = new Obs(2);
obs.setFormField("someNameSpace", "somePath");
resetObs(obs);
assertFalse(obs.isDirty());
assertNotNull(obs.getFormFieldNamespace());
assertNotNull(obs.getFormFieldPath());
obs.setFormField(null, null);
assertTrue(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test
public void setFormField_shouldMarkTheObsAsDirtyWhenTheValueIsChangedFromANullToANonNullValue() throws Exception {
Obs obs = new Obs(5);
assertNull(obs.getFormFieldNamespace());
assertNull(obs.getFormFieldPath());
obs.setFormField("someNameSpace", "somePath");
assertTrue(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setFormField(String,String)
*/
@Test
public void setFormField_shouldMarkTheObsAsDirtyWhenTheValueHasBeenChanged() throws Exception {
Obs obs = createObs(5);
final String newNameSpace = "someNameSpace";
final String newPath = "somePath";
assertNotEquals(newPath, obs.getFormFieldNamespace());
assertNotEquals(newNameSpace, obs.getFormFieldPath());
obs.setFormField(newNameSpace, newPath);
assertTrue(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());
内容来源于网络,如有侵权,请联系作者删除!