LoginCredentials creds = LoginCredentials.builder().user("myuser").password("mypass").authenticateSudo(true).build();
ByteSource bytes = toBytesFunc.apply(creds);
LoginCredentials deserializedCreds = (LoginCredentials) fromBytesFunc.apply(bytes);
String json = bytes.asCharSource(Charsets.UTF_8).read();
assertEquals(json, "{\"user\":\"myuser\",\"password\":\"mypass\",\"authenticateSudo\":true}");
assertEquals(deserializedCreds.identity, creds.identity);
assertEquals(deserializedCreds.credential, creds.credential);
assertEquals(deserializedCreds.getUser(), creds.getUser());