### Question:
RdsConfigToRdsDetailsConverter extends AbstractConversionServiceAwareConverter<RDSConfig, RdsDetails> { @Override public RdsDetails convert(RDSConfig source) { RdsDetails rdsDetails = new RdsDetails(); rdsDetails.setConnectionDriver(source.getConnectionDriver()); rdsDetails.setConnectionURL(source.getConnectionURL()); rdsDetails.setConnectorJarUrl(source.getConnectorJarUrl()); rdsDetails.setCreationDate(source.getCreationDate()); rdsDetails.setDatabaseEngine(source.getDatabaseEngine().name()); if (DatabaseVendor.EMBEDDED == source.getDatabaseEngine()) { rdsDetails.setExternal(Boolean.FALSE); } else { rdsDetails.setExternal(Boolean.TRUE); } rdsDetails.setDescription(source.getDescription()); rdsDetails.setId(source.getId()); rdsDetails.setName(source.getName()); rdsDetails.setStackVersion(source.getStackVersion()); rdsDetails.setStatus(source.getStatus().name()); rdsDetails.setType(source.getType()); if (source.getWorkspace() != null) { rdsDetails.setWorkspaceId(source.getWorkspace().getId()); } else { rdsDetails.setWorkspaceId(restRequestThreadLocalService.getRequestedWorkspaceId()); } if (restRequestThreadLocalService.getCloudbreakUser() != null) { rdsDetails.setUserName(restRequestThreadLocalService.getCloudbreakUser().getUsername()); rdsDetails.setUserId(restRequestThreadLocalService.getCloudbreakUser().getUserId()); rdsDetails.setTenantName(restRequestThreadLocalService.getCloudbreakUser().getTenant()); } return rdsDetails; }  @Override RdsDetails convert(RDSConfig source);  }### Answer:
@Test public void testWhenSourceWorkspaceIdIsNotNullThenItsValueShouldBePassedBesideAllLogicIndependentData() { Workspace workspace = new Workspace(); workspace.setId(23L); source.setWorkspace(workspace); RdsDetails result = underTest.convert(source); assertNotNull(result); assertEquals(source.getWorkspace().getId(), result.getWorkspaceId()); verify(restRequestThreadLocalService, times(0)).getRequestedWorkspaceId(); }
@Test public void testWhenSourceWorkspaceIdIsNullThenItsValueShouldBePassedBesideAllLogicIndependentData() { source.setWorkspace(null); RdsDetails result = underTest.convert(source); assertNotNull(result); assertEquals(WORKSPACE_ID_FROM_REQUEST, result.getWorkspaceId()); verify(restRequestThreadLocalService, times(1)).getRequestedWorkspaceId(); }
@Test public void testWhenDatabaseEngineIsEmbeddedThenIsExternalShouldBeFalseOtherwiseTrue() { RdsDetails result = underTest.convert(source); assertNotNull(result); if (source.getDatabaseEngine() == DatabaseVendor.EMBEDDED) { assertFalse(result.getExternal()); } else { assertTrue(result.getExternal()); } }
@Test public void testAllLogicIndependentDataArePassedProperly() { RdsDetails result = underTest.convert(source); assertNotNull(result); assertEquals(source.getConnectionDriver(), result.getConnectionDriver()); assertEquals(source.getConnectionURL(), result.getConnectionURL()); assertEquals(source.getConnectorJarUrl(), result.getConnectorJarUrl()); assertEquals(source.getCreationDate(), result.getCreationDate()); assertEquals(source.getDatabaseEngine().name(), result.getDatabaseEngine()); assertEquals(source.getDescription(), result.getDescription()); assertEquals(source.getId(), result.getId()); assertEquals(source.getName(), result.getName()); assertEquals(source.getStackVersion(), result.getStackVersion()); assertEquals(source.getStatus().name(), result.getStatus()); assertEquals(source.getType(), result.getType()); assertEquals(cloudbreakUser.getUsername(), result.getUserName()); assertEquals(cloudbreakUser.getUserId(), result.getUserId()); assertEquals(cloudbreakUser.getTenant(), result.getTenantName()); verify(restRequestThreadLocalService, times(4)).getCloudbreakUser(); }