ClientConfig { @NotNull public static ClientConfig createFrom(@NotNull ServerConfig serverConfig, @NotNull ConfigPart data) { if (!isValidClientConfig(serverConfig, data)) { throw new IllegalArgumentException("did not validate data"); } return new ClientConfig(serverConfig, data); } private  ClientConfig(@NotNull ServerConfig serverConfig, @NotNull ConfigPart data); @NotNull static ClientConfig createFrom(@NotNull ServerConfig serverConfig, @NotNull ConfigPart data); static boolean isValidClientConfig(@Nullable ServerConfig serverConfig, @Nullable ConfigPart part); int getConfigVersion(); @NotNull String getClientServerUniqueId(); @NotNull ServerConfig getServerConfig(); @Nullable String getClientname(); @Nullable String getClientHostName(); @Nullable String getIgnoreFileName(); @Nullable String getDefaultCharSet(); @Nullable String getCharSetName(); @NotNull ClientServerRef getClientServerRef(); boolean isIn(@NotNull ServerConfig config); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test void createFrom_invalid_invalidServerConfigSettings() { MockConfigPart data = new MockConfigPart() .withUsername("u") .withServerName("blah") .withClientname("c"); ServerConfig sc = ServerConfig.createFrom(data); data.withUsername(null).withServerName(null); ClientConfig.createFrom(sc, data); }
@Test void createFrom_invalid_noClientname() { MockConfigPart data = new MockConfigPart() .withUsername("u") .withServerName("blah"); assertThrows(IllegalArgumentException.class, () -> ClientConfig.createFrom( ServerConfig.createFrom(data), data )); }
@Test void createFrom_invalid_errors() { MockConfigPart data = new MockConfigPart() .withServerName("blah") .withUsername("u") .withClientname("c"); ServerConfig sc = ServerConfig.createFrom(data); data.withConfigProblems(createError()); assertThrows(IllegalArgumentException.class, () -> ClientConfig.createFrom( sc, data )); }