@Test public void testReaderWithUsernameAndPasswordInConfigFileShouldSuccess() { final Publication publication = new Publication().setPort(443).setHost("Test Host").setClientAppsMode(Publication.MODE.IGNORE) .setUsername("abcd").setPassword("efgh").setForce(false).setIgnoreAdminAccount(false) .setIgnoreQuotas(true).setClientOrgsMode(Publication.MODE.IGNORE).setApis( Collections.singletonList(new Api().setApiSpecification("api spec").setApiConfig("apiconfig"))); final String publicationString1 = new Gson().toJson(publication); StringReader stringReader = new StringReader(publicationString1); final Publication publication2 = new PublicationReader().read(stringReader, Publication.class); assertThat(publication2.getUsername(), is(publication.getUsername())); assertThat(publication2.getPassword(), is(publication.getPassword())); }
public <T> T read(String f, Class<T> classOfT) throws StageConfigNotFoundException, StageConfigFileInvalidFormatException, StageConfigFileIOException { try { final Reader reader = new FileReader(f); return read(reader, classOfT); } catch (JsonIOException e) { throw new StageConfigFileIOException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new StageConfigNotFoundException(e.getMessage(), e); } catch (JsonSyntaxException e) { throw new StageConfigFileInvalidFormatException(e.getMessage(), e); } }
PublicationReader { public <T> T read(String f, Class<T> classOfT) throws StageConfigNotFoundException, StageConfigFileInvalidFormatException, StageConfigFileIOException { try { final Reader reader = new FileReader(f); return read(reader, classOfT); } catch (JsonIOException e) { throw new StageConfigFileIOException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new StageConfigNotFoundException(e.getMessage(), e); } catch (JsonSyntaxException e) { throw new StageConfigFileInvalidFormatException(e.getMessage(), e); } } }
PublicationReader { public <T> T read(String f, Class<T> classOfT) throws StageConfigNotFoundException, StageConfigFileInvalidFormatException, StageConfigFileIOException { try { final Reader reader = new FileReader(f); return read(reader, classOfT); } catch (JsonIOException e) { throw new StageConfigFileIOException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new StageConfigNotFoundException(e.getMessage(), e); } catch (JsonSyntaxException e) { throw new StageConfigFileInvalidFormatException(e.getMessage(), e); } }  }
PublicationReader { public <T> T read(String f, Class<T> classOfT) throws StageConfigNotFoundException, StageConfigFileInvalidFormatException, StageConfigFileIOException { try { final Reader reader = new FileReader(f); return read(reader, classOfT); } catch (JsonIOException e) { throw new StageConfigFileIOException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new StageConfigNotFoundException(e.getMessage(), e); } catch (JsonSyntaxException e) { throw new StageConfigFileInvalidFormatException(e.getMessage(), e); } }  T read(String f, Class<T> classOfT); T read(Reader r, Class<T> classOfT); }
PublicationReader { public <T> T read(String f, Class<T> classOfT) throws StageConfigNotFoundException, StageConfigFileInvalidFormatException, StageConfigFileIOException { try { final Reader reader = new FileReader(f); return read(reader, classOfT); } catch (JsonIOException e) { throw new StageConfigFileIOException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new StageConfigNotFoundException(e.getMessage(), e); } catch (JsonSyntaxException e) { throw new StageConfigFileInvalidFormatException(e.getMessage(), e); } }  T read(String f, Class<T> classOfT); T read(Reader r, Class<T> classOfT);  }