use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class CredentialProviderRegistryTest method shouldFetchProvidersFromDataManager.
@Test
public void shouldFetchProvidersFromDataManager() {
final DataManager dataManager = mock(DataManager.class);
final CredentialProviderRegistry registry = new CredentialProviderRegistry(dataManager);
final Connector connector = new Connector.Builder().id("test-provider").putProperty("clientId", new ConfigurationProperty.Builder().addTag(Credentials.CLIENT_ID_TAG).build()).putProperty("clientSecret", new ConfigurationProperty.Builder().addTag(Credentials.CLIENT_SECRET_TAG).build()).putConfiguredProperty("clientId", "a-client-id").putConfiguredProperty("clientSecret", "a-client-secret").build();
when(dataManager.fetch(Connector.class, "test-provider")).thenReturn(connector);
assertThat(registry.providerWithId("test-provider")).isInstanceOfSatisfying(TestCredentialProvider.class, p -> {
assertThat(p.getProperties().getAppId()).isEqualTo("a-client-id");
assertThat(p.getProperties().getAppSecret()).isEqualTo("a-client-secret");
});
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class IntegrationHandler method getIntegration.
// **************************
// Helpers
// **************************
public Integration getIntegration(String id) {
final DataManager dataManager = getDataManager();
final Integration integration = dataManager.fetch(Integration.class, id);
if (integration == null) {
throw new EntityNotFoundException();
}
return integration;
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class IntegrationHandler method toCurrentIntegrationOverview.
public IntegrationOverview toCurrentIntegrationOverview(Integration integration) {
final DataManager dataManager = getDataManager();
final String id = integration.getId().get();
final IntegrationOverview.Builder builder = new IntegrationOverview.Builder().createFrom(integration);
// add board
DataManagerSupport.fetchBoard(dataManager, IntegrationBulletinBoard.class, id).ifPresent(builder::board);
// Defaults
builder.isDraft(true);
builder.currentState(IntegrationDeploymentState.Unpublished);
builder.targetState(IntegrationDeploymentState.Unpublished);
// Get the latest connection.
builder.connections(integration.getConnections().stream().map(this::toCurrentConnection).collect(Collectors.toList()));
// Get the latest steps.
builder.steps(integration.getSteps().stream().map(this::toCurrentSteps).collect(Collectors.toList()));
for (IntegrationDeployment deployment : dataManager.fetchAll(IntegrationDeployment.class, new IdPrefixFilter<>(id + ":"), ReverseFilter.getInstance())) {
builder.addDeployment(IntegrationDeploymentOverview.of(deployment));
if (deployment.getVersion() == integration.getVersion()) {
builder.isDraft(deployment.getVersion() != integration.getVersion());
builder.targetState(deployment.getTargetState());
builder.currentState(deployment.getCurrentState());
builder.deploymentVersion(deployment.getVersion());
}
}
return builder.build();
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class ConnectionHandler method list.
@Override
public ListResult<ConnectionOverview> list(@Context UriInfo uriInfo) {
final DataManager dataManager = getDataManager();
final ListResult<Connection> connections = fetchAll(Connection.class, uriInfo);
final List<ConnectionOverview> overviews = new ArrayList<>(connections.getTotalCount());
for (Connection connection : connections.getItems()) {
final String id = connection.getId().get();
final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
// set the connector
DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
// set the board
DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
overviews.add(builder.build());
}
return ListResult.of(overviews);
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class ConnectionHandler method get.
@Override
public ConnectionOverview get(final String id) {
final DataManager dataManager = getDataManager();
final Connection connection = dataManager.fetch(Connection.class, id);
if (connection == null) {
throw new EntityNotFoundException();
}
final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
// set the connector
DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
// set the board
DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
return builder.build();
}
Aggregations