DockerRegistryCredentials { public static DockerRegistryCredentials from(@Nonnull String username, @Nonnull String password) { DockerCloudUtils.requireNonNull(username, "Username cannot be null."); DockerCloudUtils.requireNonNull(password, "Password cannot be null."); username = username.trim(); if (username.isEmpty()) { throw new IllegalArgumentException("Username cannot be empty."); } return new DockerRegistryCredentials(username, password); } private  DockerRegistryCredentials(String username, String password); static DockerRegistryCredentials from(@Nonnull String username, @Nonnull String password); @Nonnull String getUsername(); @Nonnull String getPassword(); boolean isAnonymous(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final DockerRegistryCredentials ANONYMOUS; }
@Test public void invalidConstructorInput() { assertThatExceptionOfType(NullPointerException.class).isThrownBy( () -> DockerRegistryCredentials.from(null, "pwd")); assertThatExceptionOfType(NullPointerException.class).isThrownBy( () -> DockerRegistryCredentials.from("usr", null)); assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy( () -> DockerRegistryCredentials.from("", "pwd")); }