### Question:
UpgradeUtil { public static Integer getConceptIdForUnits(String units) { String appDataDir = OpenmrsUtil.getApplicationDataDirectory(); Properties props = new Properties(); String conceptId = null; String filePath = appDataDir + System.getProperty("file.separator") + DatabaseUtil.ORDER_ENTRY_UPGRADE_SETTINGS_FILENAME; try (FileInputStream fis = new FileInputStream(filePath)) { props.load(fis); for (Map.Entry prop : props.entrySet()) { if (prop.getKey().equals(units)) { conceptId = prop.getValue().toString(); return Integer.valueOf(conceptId); } } } catch (NumberFormatException e) { throw new APIException("Your order entry upgrade settings file" + "contains invalid mapping from " + units + " to concept ID " + conceptId + ". ID must be an integer or null. Please refer to upgrade instructions for more details. https: } catch (IOException e) { if (e instanceof FileNotFoundException) { throw new APIException("Unable to find file named order_entry_upgrade_settings.txt containing order entry upgrade settings in your " + "application data directory: " + appDataDir + "\nPlease refer to upgrade instructions for more details. https: } else { throw new APIException(e); } } throw new APIException("Your order entry upgrade settings file" + " does not have mapping for " + units + ". Please refer to upgrade instructions for more details. https: } private  UpgradeUtil(); static Integer getConceptIdForUnits(String units); static String getConceptUuid(Connection connection, int conceptId); static String getGlobalProperty(Connection connection, String gp); static List<Integer> getMemberSetIds(Connection connection, String conceptUuid); static Integer getOrderFrequencyIdForConceptId(Connection connection, Integer conceptIdForFrequency);  }### Answer:
@Test public void getConceptIdForUnits_shouldReturnConcept_idForDrug_order_quantity_units() throws IOException { Database1_9_7UpgradeIT.createOrderEntryUpgradeFileWithTestData("mg=5401" + "\n" + "drug_order_quantity_units=5403" + "\n" + "ounces=5402"); Integer conceptId = UpgradeUtil.getConceptIdForUnits("drug_order_quantity_units"); Assert.assertThat(conceptId, Is.is(5403)); }
@Test(expected = APIException.class) public void getConceptIdForUnits_shouldFailIfUnitsIsNotSpecified() throws IOException { Database1_9_7UpgradeIT.createOrderEntryUpgradeFileWithTestData("mg=540" + "\n" + "ounces=5402"); UpgradeUtil.getConceptIdForUnits("drug_order_quantity_units"); }