Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name for target node in release path is not displayed #70 #72

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/main/docker/postgresql.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: '2'
version: '3.1'
services:
microcatalog-postgresql:
image: postgres:12.3
# volumes:
# - ~/volumes/jhipster/microcatalog/postgresql/:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=microcatalog
- POSTGRES_PASSWORD=
- POSTGRES_HOST_AUTH_METHOD=trust
db:
image: postgres
restart: always
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: kEt#uR6M
adminer:
image: adminer
restart: always
ports:
- 9080:8080
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ public ReleasePathCustomService(GraphLoaderService graphLoaderService) {

public Optional<ReleasePath> getReleasePath(final Long microserviceId) {
final Graph<Microservice, DefaultEdge> graph = graphLoaderService.loadGraph();
final Microservice target = new Microservice();
target.setId(microserviceId);

final Optional<Microservice> maybeTarget = graph.vertexSet()
.stream().filter(v -> Objects.equals(v.getId(), microserviceId)).findFirst();

// can't build release path, cause microservice with given id is not present in graph
if (!graph.containsVertex(target)) {
if (!maybeTarget.isPresent()) {
return Optional.empty();
}

final Microservice target = maybeTarget.get();

final ConnectivityInspector<Microservice, DefaultEdge> inspector = new ConnectivityInspector<>(graph);
final Set<Microservice> connectedSet = inspector.connectedSetOf(target);

Expand Down
80 changes: 80 additions & 0 deletions src/main/resources/config/application-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ===================================================================
# Spring Boot configuration for the "heroku" profile.
#
# This configuration overrides the application.yml file.
# ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================

spring:
liquibase:
enabled: true
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.postgresql.Driver
url: ${JDBC_DATABASE_URL}
username: ${JDBC_DATABASE_USERNAME}
password: ${JDBC_DATABASE_PASSWORD}
hikari:
poolName: Hikari
auto-commit: false
jpa:
database-platform: io.github.jhipster.domain.util.FixedPostgreSQL10Dialect
show-sql: false
h2:
console:
enabled: false
mail:
host: localhost
port: 25
username:
password:
thymeleaf:
cache: true

server:
port: 8080
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
min-response-size: 1024

jhipster:
http:
cache: # Used by the CachingHttpHeadersFilter
timeToLiveInDays: 1461
cache: # Cache configuration
ehcache: # Ehcache configuration
time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
max-entries: 1000 # Number of objects in each cache entry
security:
authentication:
jwt:
# This token must be encoded using Base64 and be at least 256 bits long (you can type `openssl rand -base64 64` on your command line to generate a 512 bits one)
# As this is the PRODUCTION configuration, you MUST change the default key, and store it securely:
# - In the JHipster Registry (which includes a Spring Cloud Config server)
# - In a separate `application-prod.yml` file, in the same folder as your executable JAR file
# - In the `JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64_SECRET` environment variable
base64-secret: YzljOTRhYTYwMDkwM2RhYjIxOGU2MTNjMDRjMDIyMjJjNjUyMzlmNzM5MjU1MzY3ZDI4NWFkY2YxNTM1YmI3N2EyZjRiNGE3OGZlYzcxNjJkYmRiNDNlNGFjYzI2YWZjMWNiYzI3NjE1NmVlMWJhMWVjNzZhNzhhNDY4Yzg0MzA=
# Token is valid 24 hours
token-validity-in-seconds: 86400
token-validity-in-seconds-for-remember-me: 2592000
mail: # specific JHipster mail property, for standard properties see MailProperties
base-url: http://my-server-url-to-change # Modify according to your server's URL
metrics:
logs: # Reports metrics in the logs
enabled: false
report-frequency: 60 # in seconds
logging:
use-json-format: false # By default, logs are not in Json format
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
enabled: false
host: localhost
port: 5000
queue-size: 512
audit-events:
retention-period: 30 # Number of days before audit events are deleted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.github.microcatalog.web.rest.errors.custom;

import com.github.microcatalog.service.custom.exceptions.CircularDependenciesException;
import com.github.microcatalog.service.custom.exceptions.SelfCircularException;
import com.github.microcatalog.utils.MicroserviceBuilder;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.NativeWebRequest;
import org.zalando.problem.Problem;

import java.util.Arrays;
import java.util.HashSet;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.mockito.Mockito.spy;

@ExtendWith(MockitoExtension.class)
class ReleasePathAdviceTraitTest {

private final ReleasePathAdviceTrait cut = spy(ReleasePathAdviceTrait.class);

@Mock
private NativeWebRequest webRequest;

@Test
void handleSelfCircularException() {

final SelfCircularException exception =
new SelfCircularException("Test message", new MicroserviceBuilder().withId(1L).build());
ResponseEntity<Problem> response = cut.handleSelfCircularException(exception, webRequest);

assertThat(response).isNotNull()
.extracting(HttpEntity::getBody).isNotNull();

assertThat(response.getStatusCodeValue()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY.value());

assertThat(response.getBody()).isNotNull()
.extracting(Problem::getParameters, InstanceOfAssertFactories.map(String.class, Object.class))
.contains(
entry(ReleasePathAdviceTrait.HEADER_KEY, exception.getClass().getName()),
entry(ReleasePathAdviceTrait.MESSAGE_KEY, "Test message"),
entry(ReleasePathAdviceTrait.PAYLOAD_KEY, "id = 1, name = null")
);
}

@Test
void handleCircularDependenciesException() {
final CircularDependenciesException exception =
new CircularDependenciesException("Test message", new HashSet<>(Arrays.asList(
new MicroserviceBuilder().withId(1L).build(),
new MicroserviceBuilder().withId(2L).build(),
new MicroserviceBuilder().withId(3L).build()
)));

ResponseEntity<Problem> response = cut.handleCircularDependenciesException(exception, webRequest);

assertThat(response).isNotNull()
.extracting(HttpEntity::getBody).isNotNull();

assertThat(response.getStatusCodeValue()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY.value());

assertThat(response.getBody()).isNotNull()
.extracting(Problem::getParameters, InstanceOfAssertFactories.map(String.class, Object.class))
.contains(
entry(ReleasePathAdviceTrait.HEADER_KEY, exception.getClass().getName()),
entry(ReleasePathAdviceTrait.MESSAGE_KEY, "Test message"),
entry(ReleasePathAdviceTrait.PAYLOAD_KEY, "1,2,3")
);
}
}