@Bean @ConditionalOnProperty(prefix="edison.serviceregistry", name="enabled", havingValue = "true") public ServiceDependency serviceRegistryDependency() { return ServiceDependencyBuilder.serviceDependency(serviceRegistryProperties.getServers()) .withName("Service Registry") .withDescription("Registers this service at a service registry") .withExpectations(expects(Availability.MEDIUM, Performance.MEDIUM)) .withCriticality(Criticality.criticality(Level.HIGH, "Service cannot be registered")) .build(); }
@Test public void shouldBuildServiceDependency() { final ServiceDependency dependency = serviceDependency("http://example.com") .withName("name") .withDescription("description") .withMediaTypes(singletonList("application/json")) .withMethods(asList("GET", "HEAD")) .withAuthentication(AUTH_HMAC) .build(); assertThat(dependency.getName()).isEqualTo("name"); assertThat(dependency.getDescription()).isEqualTo("description"); assertThat(dependency.getAuthentication()).isEqualTo("HMAC"); assertThat(dependency.getMediaTypes()).contains("application/json"); assertThat(dependency.getMethods()).contains("GET", "HEAD"); assertThat(dependency.getType()).isEqualTo("service"); assertThat(dependency.getSubtype()).isEqualTo("OTHER"); assertThat(dependency.getUrl()).isEqualTo("http://example.com"); }
@Test public void shouldCopyServiceDependency() { final ServiceDependency dependency = serviceDependency("http://example.com") .withName("name") .withDescription("description") .withMediaTypes(singletonList("application/json")) .withAuthentication(AUTH_HMAC) .withMethods(asList("GET", "HEAD")) .withType("some type") .withSubtype("some subtype") .build(); assertThat(dependency).isEqualTo(copyOf(dependency).build()); assertThat(dependency.hashCode()).isEqualTo(copyOf(dependency).build().hashCode()); }