### Question:
Info2 { private Image findFirmwareImage(String hardware, String model, String build, Transform transform) throws JSONException, IllegalFirmwareFile { JSONObject models= root.getJSONObject(hardware); JSONObject builds = models.getJSONObject(model); JSONObject versions = builds.getJSONObject(build); return transform.apply(versions); } Info2(JSONObject root, String apiVersionStr); Image findFirmwareImage(String hardware, String model, String build); Image findFirmwareImage(String hardware, String model, String build, String version); List<Image> findBootloaderImages(String hardware, String model, String key, String current);  }### Answer:
@Test public void findSpecificFirmware() throws JSONException, IllegalFirmwareFile { final String hardware = "0.4"; final String model = "5"; final String build = "vanilla"; Image expected = new Image(hardware, model, build, "1.4.5", "firmware.zip", "0.3.3", "3.6.0"); assertEquals(expected, info.findFirmwareImage(hardware, model, build, "1.4.5")); }
@Test(expected = IllegalFirmwareFile.class) public void findSpecificFirmwareWithOldApi() throws JSONException, IllegalFirmwareFile { final String hardware = "0.2"; final String model = "6"; final String build = "vanilla"; info.findFirmwareImage(hardware, model, build, "2.7.11"); }
@Test(expected = IllegalFirmwareFile.class) public void findNonExistentFirmware() throws JSONException, IllegalFirmwareFile { final String hardware = "0.4"; final String model = "5"; final String build = "vanilla"; info.findFirmwareImage(hardware, model, build, "3.1.41"); }
@Test public void findLatestFirmware() throws JSONException, IllegalFirmwareFile { final String hardware = "0.1"; final String model = "5"; final String build = "vanilla"; Image expected = new Image(hardware, model, build, "1.5.0", "firmware.zip", "0.3.1", "3.5.0"); assertEquals(expected, info.findFirmwareImage(hardware, model, build)); }
@Test(expected = UnsupportedOperationException.class) public void findLatestFirmwareWithOldApi() throws JSONException, IllegalFirmwareFile { final String hardware = "0.2"; final String model = "6"; final String build = "vanilla"; info.findFirmwareImage(hardware, model, build); }