### Question:
ExternalGroups extends GenericJson { public static ExternalGroups fromConfiguration() throws IOException { checkState(Configuration.isInitialized(), "configuration must be initialized"); String groupsFilename = Configuration.getString(CONFIG_EXTERNALGROUPS_FILENAME, null).get(); logger.log(Level.CONFIG, CONFIG_EXTERNALGROUPS_FILENAME + ": " + groupsFilename); File groupsFile = new File(groupsFilename); if (!(groupsFile.exists() && groupsFile.canRead())) { throw new InvalidConfigurationException(groupsFilename + " can't be read"); } return fromFile(groupsFile); }  static ExternalGroups fromConfiguration(); static ExternalGroups fromFile(File groupsFile); List<ExternalGroup> getExternalGroups(); static final String CONFIG_EXTERNALGROUPS_FILENAME; @Key
  public List<ExternalGroup> externalGroups; }### Answer:
@Test public void multipleGroups_fromConfiguration() throws Exception { File dataFile = temporaryFolder.newFile("groups.json"); createFile(dataFile, testGroups); Properties config = new Properties(); config.put("api.identitySourceId", "test-identitySourceId"); config.put("externalgroups.filename", dataFile.toString()); setupConfig.initConfig(config); checkGroups(ExternalGroups.fromConfiguration()); }
@Test public void fromConfiguration_missingFilename_throwsException() throws Exception { Properties config = new Properties(); config.put("api.identitySourceId", "test-identitySourceId"); setupConfig.initConfig(config); thrown.expect(InvalidConfigurationException.class); ExternalGroups.fromConfiguration(); }
@Test public void fromConfiguration_missingFile_throwsException() throws Exception { Properties config = new Properties(); config.put("api.identitySourceId", "test-identitySourceId"); config.put("externalgroups.filename", "no-such-file"); setupConfig.initConfig(config); thrown.expect(InvalidConfigurationException.class); ExternalGroups.fromConfiguration(); }
@Test public void fromConfiguration_unreadableFile_throwsException() throws Exception { File dataFile = temporaryFolder.newFile("groups.json"); dataFile.setReadable(false); Properties config = new Properties(); config.put("api.identitySourceId", "test-identitySourceId"); config.put("externalgroups.filename", dataFile.toString()); setupConfig.initConfig(config); thrown.expect(InvalidConfigurationException.class); ExternalGroups.fromConfiguration(); }