SensorCoefficientFile implements SmacSensorCoefficients { public void readFile(String fileName) throws IllegalArgumentException, IOException { Guardian.assertNotNull("fileName", fileName); File coeffFile = new File(fileName); if (!coeffFile.exists() || !coeffFile.isFile()) { throw new FileNotFoundException(); } scan(coeffFile); } SensorCoefficientFile(); void readFile(String fileName); double getAh2o(); double getNh2o(); double getAo3(); double getNo3(); double getAo2(); double getNo2(); double getPo2(); double getAco2(); double getNco2(); double getPco2(); double getAch4(); double getNch4(); double getPch4(); double getAno2(); double getNno2(); double getPno2(); double getAco(); double getNco(); double getPco(); double getA0s(); double getA1s(); double getA2s(); double getA3s(); double getA0T(); double getA1T(); double getA2T(); double getA3T(); double getTaur(); double getSr(); double getA0taup(); double getA1taup(); double getWo(); double getGc(); double getA0P(); double getA1P(); double getA2P(); double getA3P(); double getA4P(); double getRest1(); double getRest2(); double getRest3(); double getRest4(); double getResr1(); double getResr2(); double getResr3(); double getResa1(); double getResa2(); double getResa3(); double getResa4();  }
@Test public void testReadFile() { SensorCoefficientFile file = new SensorCoefficientFile(); try { file.readFile(null); fail("illegal null argument shall not be accepted"); } catch (IllegalArgumentException | IOException ignored) { } try { file.readFile("gbrmtzewz"); fail("exception must be thrown when non existent file is passed in"); } catch (IOException ignored) { } try { File toRead = smacAuxDir.resolve("coef_ASTER1_DES.dat").toFile(); file.readFile(toRead.toString()); } catch (FileNotFoundException e) { fail("must be able to read this file"); } catch (IOException ignored) { } assertEquals(-0.002718, file.getAh2o(), 1e-12); assertEquals(0.758879, file.getNh2o(), 1e-12); assertEquals(-0.087688, file.getAo3(), 1e-12); assertEquals(0.994792, file.getNo3(), 1e-12); assertEquals(0.000000, file.getAo2(), 1e-12); assertEquals(0.000000, file.getNo2(), 1e-12); assertEquals(0.000000, file.getPo2(), 1e-12); assertEquals(0.000000, file.getAco2(), 1e-12); assertEquals(0.000000, file.getNco2(), 1e-12); assertEquals(0.000000, file.getPco2(), 1e-12); assertEquals(0.000000, file.getAch4(), 1e-12); assertEquals(0.000000, file.getNch4(), 1e-12); assertEquals(0.000000, file.getPch4(), 1e-12); assertEquals(0.000000, file.getAno2(), 1e-12); assertEquals(0.000000, file.getNno2(), 1e-12); assertEquals(0.000000, file.getPno2(), 1e-12); assertEquals(0.000000, file.getAco(), 1e-12); assertEquals(0.000000, file.getNco(), 1e-12); assertEquals(0.000000, file.getPco(), 1e-12); assertEquals(0.049583, file.getA0s(), 1e-12); assertEquals(0.202694, file.getA1s(), 1e-12); assertEquals(-0.069883, file.getA2s(), 1e-12); assertEquals(0.032950, file.getA3s(), 1e-12); assertEquals(1.122924, file.getA0T(), 1e-12); assertEquals(-0.171042, file.getA1T(), 1e-12); assertEquals(-0.087717, file.getA2T(), 1e-12); assertEquals(-0.243279, file.getA3T(), 1e-12); assertEquals(0.095735, file.getTaur(), 1e-12); assertEquals(0.080458, file.getSr(), 1e-12); assertEquals(1.665335e-16, file.getA0taup(), 1e-12); assertEquals(0.996574, file.getA1taup(), 1e-12); assertEquals(0.931251, file.getWo(), 1e-12); assertEquals(0.707801, file.getGc(), 1e-12); assertEquals(6.65108385405353e+00, file.getA0P(), 1e-12); assertEquals(-2.04145765556867e-01, file.getA1P(), 1e-12); assertEquals(2.47532478623969e-03, file.getA2P(), 1e-12); assertEquals(-1.37367474080701e-05, file.getA3P(), 1e-12); assertEquals(2.93421755343360e-08, file.getA4P(), 1e-12); assertEquals(-0.003809, file.getRest1(), 1e-12); assertEquals(-0.015628, file.getRest2(), 1e-12); assertEquals(-0.014170, file.getRest3(), 1e-12); assertEquals(-0.002414, file.getRest4(), 1e-12); assertEquals(-0.001115, file.getResr1(), 1e-12); assertEquals(-0.003992, file.getResr2(), 1e-12); assertEquals(0.025444, file.getResr3(), 1e-12); assertEquals(-0.008359, file.getResa1(), 1e-12); assertEquals(-0.03399, file.getResa2(), 1e-12); assertEquals(-0.042086, file.getResa3(), 1e-12); assertEquals(-0.012983, file.getResa4(), 1e-12); }