### Question:
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String  formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid();  }### Answer:
@Test public void shouldCreateNumericObservation() throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ Concept concept = mock(Concept.class); when(concept.isNumeric()).thenReturn(true); when(concept.isCoded()).thenReturn(false); Observation observation = observationParserUtility.getObservationEntity(concept, "20.0"); assertThat(observation.getValueNumeric(), is(20.0)); assertTrue(observation.getUuid().startsWith("observationFromPhoneUuid")); }
@Test public void shouldCreateObsWithStringForNonNumericNonCodedConcept() throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ observationParserUtility = new ObservationParserUtility(muzimaApplication,true); Concept concept = mock(Concept.class); when(concept.getName()).thenReturn("SomeConcept"); when(concept.isNumeric()).thenReturn(false); when(concept.isCoded()).thenReturn(false); Observation observation = observationParserUtility.getObservationEntity(concept, "someString"); assertThat(observation.getValueAsString(), is("someString")); }