/** * Creates a ServiceDependencyBuilder with type="db" and subtype="Cassandra". * * @param datasources the datasources of the accessed database. * @return builder used to configure Cassandra datasource dependencies */ public static DatasourceDependencyBuilder cassandraDependency(final Datasource... datasources) { return cassandraDependency(asList(datasources)); }
/** * Creates a generic DataSourceDependencyBuilder. * * @param datasources the datasources of the accessed database. * @return builder used to configure other datasource dependencies */ public static DatasourceDependencyBuilder datasourceDependency(final Datasource... datasources) { return datasourceDependency(asList(datasources)); }
/** * Creates a ServiceDependencyBuilder with type="db" and subtype="ElasticSearch". * * @param datasources the datasources of the accessed ES services. * @return builder used to configure ES datasource dependencies */ public static DatasourceDependencyBuilder elasticSearchDependency(final Datasource... datasources) { return elasticSearchDependency(asList(datasources)); }
/** * Creates a ServiceDependencyBuilder with type="db" and subtype="MongoDB". * * @param datasources the datasources of the accessed database. * @return builder used to configure MongoDB datasource dependencies */ public static DatasourceDependencyBuilder mongoDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_MONGODB); }
/** * Returns a builder instance that is initialized using a prototype DatasourceDependency. * <p> * All values of the prototype are copied. * </p> * @param prototype the prototype dependency * @return DatasourceDependencyBuilder */ public static DatasourceDependencyBuilder copyOf(final DatasourceDependency prototype) { return new DatasourceDependencyBuilder() .withName(prototype.getName()) .withDescription(prototype.getDescription()) .withType(prototype.getType()) .withSubtype(prototype.getSubtype()) .withDatasources(prototype.getDatasources()) .withCriticality(prototype.getCriticality()) .withExpectations(prototype.getExpectations()); }
@Test public void shouldBuildDatasourceDependency() { final DatasourceDependency dependency = datasourceDependency(datasource("foo:42/bar")) .withType("test") .withSubtype("unittest") .withName("name") .withDescription("description") .build(); assertThat(dependency.getName()).isEqualTo("name"); assertThat(dependency.getDescription()).isEqualTo("description"); assertThat(dependency.getType()).isEqualTo("test"); assertThat(dependency.getSubtype()).isEqualTo("unittest"); assertThat(dependency.getDatasources()).contains(datasource("foo", 42, "bar")); }
private DatasourceDependency someMongoDb() { return mongoDependency(asList( datasource("10.42.42.41:27001/shoppingcarts"), datasource("10.42.42.42:27001/shoppingcarts"))) .withName("shoppingcart-db") .withDescription("Shoppingcart Database") .build(); } }
@Test public void shouldReturnDependencies() throws Exception { when(externalDependencies.getDependencies()).thenReturn(asList( mongoDependency(singletonList(datasource("foo:42/bar"))).withName("test").build(), restServiceDependency("foobar:4711").build() ));
@Test public void shouldBuildMongoDatasource() { DatasourceDependency dependency = mongoDependency(singletonList(datasource("foo"))).build(); assertThat(dependency.getDatasources()).contains(datasource("foo", -1, "")); assertThat(dependency.getType()).isEqualTo("db"); assertThat(dependency.getSubtype()).isEqualTo("MongoDB"); }
@Test public void shouldBuildRedisDatasource() { DatasourceDependency dependency = redisDependency(datasource("foo")).build(); assertThat(dependency.getDatasources()).contains(datasource("foo", -1, "")); assertThat(dependency.getType()).isEqualTo("db"); assertThat(dependency.getSubtype()).isEqualTo("Redis"); }
@Test public void shouldBuildCassandraDatasource() { DatasourceDependency dependency = cassandraDependency(datasource("foo")).build(); assertThat(dependency.getDatasources()).contains(datasource("foo", -1, "")); assertThat(dependency.getType()).isEqualTo("db"); assertThat(dependency.getSubtype()).isEqualTo("Cassandra"); }
@Test public void shouldBuildElasticSearchDatasource() { DatasourceDependency dependency = elasticSearchDependency(datasource("foo")).build(); assertThat(dependency.getDatasources()).contains(datasource("foo", -1, "")); assertThat(dependency.getType()).isEqualTo("db"); assertThat(dependency.getSubtype()).isEqualTo("ElasticSearch"); }
@Test public void shouldBuildKafkaDatasource() { DatasourceDependency dependency = kafkaDependency(datasource("foo")).build(); assertThat(dependency.getDatasources()).contains(datasource("foo", -1, "")); assertThat(dependency.getType()).isEqualTo("queue"); assertThat(dependency.getSubtype()).isEqualTo("Kafka"); }
/** * Creates a ServiceDependencyBuilder with type="queue" and subtype="Kafka". * * @param datasources the datasources of the accessed queue. * @return builder used to configure Kafka datasource dependencies */ public static DatasourceDependencyBuilder kafkaDependency(final Datasource... datasources) { return kafkaDependency(asList(datasources)); }
/** * Creates a ServiceDependencyBuilder with type="db" and subtype="Redis". * * @param datasources the datasources of the accessed database. * @return builder used to configure Redis datasource dependencies */ public static DatasourceDependencyBuilder redisDependency(final Datasource... datasources) { return redisDependency(asList(datasources)); }
/** * Creates a ServiceDependencyBuilder with type="db" and subtype="MongoDB". * * @param datasources the datasources of the accessed database. * @return builder used to configure MongoDB datasource dependencies */ public static DatasourceDependencyBuilder mongoDependency(final Datasource... datasources) { return mongoDependency(asList(datasources)); }
/** * Creates a ServiceDependencyBuilder with type="queue" and subtype="Kafka". * * @param datasources the datasources of the accessed queue. * @return builder used to configure Kafka datasource dependencies */ public static DatasourceDependencyBuilder kafkaDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_QUEUE) .withSubtype(DatasourceDependency.SUBTYPE_KAFKA); }
@Test public void shouldReturnCriticalityAndExpectations() throws Exception { when(externalDependencies.getDependencies()).thenReturn(asList( mongoDependency(singletonList(datasource("foo:42/bar"))).build(), restServiceDependency("foobar:4711") .withCriticality(criticality(HIGH, "Bad. Really bad."))
/** * Creates a ServiceDependencyBuilder with type="db" and subtype="Cassandra". * * @param datasources the datasources of the accessed database. * @return builder used to configure Cassandra datasource dependencies */ public static DatasourceDependencyBuilder cassandraDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_CASSANDRA); }