@Test public void checkGcpWindowsPlatformData() throws Exception { BufferedReader reader; reader = new BufferedReader(new StringReader("Product : Google")); assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("Manufacturer : LENOVO")); assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("Manufacturer : Google Compute Engine")); assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("Manufacturer : Google")); assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("Manufacturer:Google")); assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("Manufacturer : Google ")); assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); reader = new BufferedReader(new StringReader("BIOSVersion : 1.0\nManufacturer : Google\n")); assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); }
@VisibleForTesting static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.startsWith("Manufacturer")) { String name = line.substring(line.indexOf(':') + 1).trim(); return name.equals("Google"); } } return false; }
CheckGcpEnvironment { @VisibleForTesting static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.startsWith("Manufacturer")) { String name = line.substring(line.indexOf(':') + 1).trim(); return name.equals("Google"); } } return false; } }
CheckGcpEnvironment { @VisibleForTesting static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.startsWith("Manufacturer")) { String name = line.substring(line.indexOf(':') + 1).trim(); return name.equals("Google"); } } return false; } private  CheckGcpEnvironment(); }
CheckGcpEnvironment { @VisibleForTesting static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.startsWith("Manufacturer")) { String name = line.substring(line.indexOf(':') + 1).trim(); return name.equals("Google"); } } return false; } private  CheckGcpEnvironment();  }
CheckGcpEnvironment { @VisibleForTesting static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.startsWith("Manufacturer")) { String name = line.substring(line.indexOf(':') + 1).trim(); return name.equals("Google"); } } return false; } private  CheckGcpEnvironment();   }