/** * @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()); }
/** * @see Obs#getFormFieldNamespace() */ @Test public void getFormFieldNamespace_shouldReturnNullIfTheNamespaceIsNotSpecified() throws Exception { Obs obs = new Obs(); obs.setFormField("", "my path"); Assert.assertNull(obs.getFormFieldNamespace()); }
/** * @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()); }
/** * @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()); }
/** * @see ObsService#saveObs(Obs,String) */ @Test public void saveObs_shouldCopyTheFormNamespaceAndPathFieldInEditedObs() { executeDataSet(INITIAL_OBS_XML); Obs obs = Context.getObsService().getObs(7); obs.setValueNumeric(5.0); Obs o2 = Context.getObsService().saveObs(obs, "just testing"); Assert.assertNotNull(obs.getFormFieldNamespace()); // fetch the obs from the database again obs = Context.getObsService().getObs(o2.getObsId()); Assert.assertNotNull(obs.getFormFieldNamespace()); Assert.assertNotNull(obs.getFormFieldPath()); }
/** * @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()); }
/** * @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()); }
/** * @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()); }
newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());