### Question:
CredentialToCloudCredentialConverter implements Converter<Credential, CloudCredential> { public CloudCredential convert(Credential credential) { if (credential == null) { return null; } Map<String, Object> fields = isEmpty(credential.getAttributes()) ? new HashMap<>() : new Json(credential.getAttributes()).getMap(); return new CloudCredential(credential.getCrn(), credential.getName(), fields, false); }  CloudCredential convert(Credential credential);  }### Answer:
@Test public void testConvert() { credential = new Credential("userCrn", "userId", "{ \"foo\": \"bar\" }"); CloudCredential cloudCredential = underTest.convert(credential); assertEquals("userCrn", cloudCredential.getId()); assertEquals("userId", cloudCredential.getName()); assertEquals(1, cloudCredential.getParameters().size()); assertEquals("bar", cloudCredential.getParameters().get("foo")); }
@Test public void testConvertNoAttributes() { credential = new Credential("userCrn", "userId", null); CloudCredential cloudCredential = underTest.convert(credential); assertEquals("userCrn", cloudCredential.getId()); assertEquals("userId", cloudCredential.getName()); assertTrue(cloudCredential.getParameters().isEmpty()); }
@SuppressFBWarnings(value = "NP", justification = "Converter may be passed a null") @Test public void testConvertNull() { assertNull(underTest.convert(null)); }