@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(); }
@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; }
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; } }
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; }  }
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); }
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);  }