use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class ExtensionDataManagerTest method shouldGetCorrectDataByExtensionId.
@Test
public void shouldGetCorrectDataByExtensionId() throws IOException {
final DataManager dataManager = mock(DataManager.class);
final FileDAO extensionDataAccess = mock(FileDAO.class);
final FileDataManager extensionDataManager = new FileDataManager(dataManager, extensionDataAccess);
String sampleBinaryData = "Hello";
Extension sampleMetadata = new Extension.Builder().id("1234").status(Extension.Status.Installed).extensionId("extensionId").description("Description").build();
when(extensionDataAccess.read("/extensions/1234")).thenReturn(new ByteArrayInputStream(sampleBinaryData.getBytes(StandardCharsets.UTF_8)));
when(dataManager.fetchIdsByPropertyValue(Extension.class, "extensionId", "extensionId", "status", Extension.Status.Installed.name())).thenReturn(Collections.singleton("1234"));
when(dataManager.fetch(Extension.class, "1234")).thenReturn(sampleMetadata);
assertThat(extensionDataManager.getExtensionMetadata("extensionId")).isEqualTo(sampleMetadata);
assertThat(IOUtils.toString(extensionDataManager.getExtensionBinaryFile("extensionId"), StandardCharsets.UTF_8)).isEqualTo(sampleBinaryData);
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class MetricsCollectorTest method before.
@Before
public void before() throws IOException, ParseException {
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
DBI dbi = new DBI(ds);
this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key")));
try {
this.jsondb.dropTables();
} catch (Exception e) {
}
this.jsondb.createTables();
jsondbRM = new JsonDBRawMetrics(jsondb);
load();
CacheManager cacheManager = new LRUCacheManager(100);
EncryptionComponent encryptionComponent = new EncryptionComponent(null);
ResourceLoader resourceLoader = new DefaultResourceLoader();
// Create Data Manager
dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader);
intMH = new IntegrationMetricsHandler(dataManager);
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class ConnectionUpdateHandler method compute.
@Override
protected List<ConnectionBulletinBoard> compute(ChangeEvent event) {
final List<ConnectionBulletinBoard> boards = new ArrayList<>();
final DataManager dataManager = getDataManager();
final List<Connector> connectors = dataManager.fetchAll(Connector.class).getItems();
for (int i = 0; i < connectors.size(); i++) {
final Connector connector = connectors.get(i);
final String id = connector.getId().get();
dataManager.fetchAllByPropertyValue(Connection.class, "connectorId", id).filter(connection -> connection.getConnector().isPresent()).map(connection -> computeBoard(connection, connection.getConnector().get(), connector)).forEach(boards::add);
}
return boards;
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class ConnectionUpdateHandler method computeBoard.
private ConnectionBulletinBoard computeBoard(Connection connection, Connector oldConnector, Connector newConnector) {
final DataManager dataManager = getDataManager();
final String id = connection.getId().get();
final ConnectionBulletinBoard board = dataManager.fetchByPropertyValue(ConnectionBulletinBoard.class, "targetResourceId", id).orElse(null);
final ConnectionBulletinBoard.Builder builder;
if (board != null) {
builder = new ConnectionBulletinBoard.Builder().createFrom(board).updatedAt(System.currentTimeMillis());
} else {
builder = new ConnectionBulletinBoard.Builder().id(KeyGenerator.createKey()).targetResourceId(id).createdAt(System.currentTimeMillis());
}
List<LeveledMessage> messages = new ArrayList<>();
messages.addAll(computeValidatorMessages(LeveledMessage.Builder::new, connection));
messages.addAll(computePropertiesDiffMessages(LeveledMessage.Builder::new, oldConnector.getProperties(), newConnector.getProperties()));
messages.addAll(computeMissingMandatoryPropertiesMessages(LeveledMessage.Builder::new, newConnector.getProperties(), connection.getConfiguredProperties()));
messages.addAll(computeSecretsUpdateMessages(LeveledMessage.Builder::new, newConnector.getProperties(), connection.getConfiguredProperties()));
builder.errors(countMessagesWithLevel(LeveledMessage.Level.ERROR, messages));
builder.warnings(countMessagesWithLevel(LeveledMessage.Level.WARN, messages));
builder.notices(countMessagesWithLevel(LeveledMessage.Level.INFO, messages));
builder.putMetadata("connector-id", newConnector.getId().get());
builder.putMetadata("connector-version-latest", Integer.toString(newConnector.getVersion()));
builder.putMetadata("connector-version-connection", Integer.toString(oldConnector.getVersion()));
builder.messages(messages);
return builder.build();
}
use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.
the class CredentialProviderRegistryTest method shouldComplainAboutUnregisteredProviders.
@Test(expected = IllegalArgumentException.class)
public void shouldComplainAboutUnregisteredProviders() {
final DataManager dataManager = mock(DataManager.class);
final CredentialProviderRegistry registry = new CredentialProviderRegistry(dataManager);
registry.providerWithId("unregistered");
}
Aggregations