### Question:
GenesisFile { public static GenesisFile read(byte[] contents) throws IOException { JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(contents); int chainId = 0; String nonce = null; String difficulty = null; String mixhash = null; String coinbase = null; String timestamp = null; String extraData = null; String gasLimit = null; String parentHash = null; Map<String, String> allocs = null; Set<Long> collectedForks = new TreeSet<>(); while (!parser.isClosed()) { JsonToken jsonToken = parser.nextToken(); if (JsonToken.FIELD_NAME.equals(jsonToken)) { String fieldName = parser.getCurrentName(); parser.nextToken(); if ("nonce".equalsIgnoreCase(fieldName)) { nonce = parser.getValueAsString(); } else if ("difficulty".equalsIgnoreCase(fieldName)) { difficulty = parser.getValueAsString(); } else if ("mixHash".equalsIgnoreCase(fieldName)) { mixhash = parser.getValueAsString(); } else if ("coinbase".equalsIgnoreCase(fieldName)) { coinbase = parser.getValueAsString(); } else if ("gasLimit".equalsIgnoreCase(fieldName)) { gasLimit = parser.getValueAsString(); } else if ("timestamp".equalsIgnoreCase(fieldName)) { timestamp = parser.getValueAsString(); } else if ("extraData".equalsIgnoreCase(fieldName)) { extraData = parser.getValueAsString(); } else if ("parentHash".equalsIgnoreCase(fieldName)) { parentHash = parser.getValueAsString(); } else if ("alloc".equalsIgnoreCase(fieldName)) { allocs = readAlloc(parser); } else if ("chainId".equalsIgnoreCase(fieldName)) { chainId = parser.getValueAsInt(); } else if (fieldName.contains("Block")) { collectedForks.add(parser.getValueAsLong()); } } } List<Long> forks = new ArrayList<>(collectedForks); Collections.sort(forks); return new GenesisFile( nonce, difficulty, mixhash, coinbase, timestamp, extraData, gasLimit, parentHash, allocs, chainId, forks); } GenesisFile(
      String nonce,
      String difficulty,
      String mixhash,
      String coinbase,
      String timestamp,
      String extraData,
      String gasLimit,
      String parentHash,
      Map<String, String> allocs,
      int chainId,
      List<Long> forks); static GenesisFile read(byte[] contents); Block toBlock(); Map<Address, Wei> getAllocations(); List<Long> getForks(); int getChainId();  }### Answer:
@Test void testMissingNonce() throws IOException { InputStream input = GenesisFileTest.class.getResourceAsStream("/missing-nonce.json"); byte[] contents = input.readAllBytes(); assertThrows(IllegalArgumentException.class, () -> GenesisFile.read(contents)); }
@Test void testMissingDifficulty() throws IOException { InputStream input = GenesisFileTest.class.getResourceAsStream("/missing-difficulty.json"); byte[] contents = input.readAllBytes(); assertThrows(IllegalArgumentException.class, () -> GenesisFile.read(contents)); }