Merge branch 'master' of https://github.com/eugenp/tutorials
This commit is contained in:
commit
a256b723c9
|
@ -2,20 +2,17 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>2.2.6.RELEASE</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>aws-app-sync</artifactId>
|
<artifactId>aws-app-sync</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<name>aws-app-sync</name>
|
<name>aws-app-sync</name>
|
||||||
|
|
||||||
<description>Spring Boot using AWS App Sync</description>
|
<description>Spring Boot using AWS App Sync</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@Disabled
|
@Disabled
|
||||||
class AwsAppSyncApplicationTests {
|
class AwsAppSyncApplicationUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenGraphQuery_whenListEvents_thenReturnAllEvents() {
|
void givenGraphQuery_whenListEvents_thenReturnAllEvents() {
|
|
@ -16,7 +16,7 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct-jdk8</artifactId>
|
<artifactId>mapstruct</artifactId>
|
||||||
<version>${org.mapstruct.version}</version>
|
<version>${org.mapstruct.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -71,12 +71,12 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
<org.mapstruct.version>1.4.0.Beta1</org.mapstruct.version>
|
||||||
<springframework.version>4.3.4.RELEASE</springframework.version>
|
<springframework.version>4.3.4.RELEASE</springframework.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<org.projectlombok.version>1.18.4</org.projectlombok.version>
|
<org.projectlombok.version>1.18.4</org.projectlombok.version>
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.16.1</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CompanyDTO {
|
||||||
|
|
||||||
|
private List<EmployeeDTO> employees;
|
||||||
|
|
||||||
|
public List<EmployeeDTO> getEmployees() {
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployees(List<EmployeeDTO> employees) {
|
||||||
|
this.employees = employees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEmployee(EmployeeDTO employeeDTO) {
|
||||||
|
if (employees == null) {
|
||||||
|
employees = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
employees.add(employeeDTO);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||||
|
|
||||||
|
public class EmployeeDTO {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||||
|
|
||||||
|
public class EmployeeFullNameDTO {
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
public String getFullName() {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullName(String fullName) {
|
||||||
|
this.fullName = fullName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
@Mapper(uses = EmployeeMapper.class)
|
||||||
|
public interface CompanyMapper {
|
||||||
|
|
||||||
|
CompanyDTO map(Company company);
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||||
|
import org.mapstruct.CollectionMappingStrategy;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
|
||||||
|
public interface CompanyMapperAdderPreferred {
|
||||||
|
|
||||||
|
CompanyDTO map(Company company);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeFullNameDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface EmployeeFullNameMapper {
|
||||||
|
|
||||||
|
List<EmployeeFullNameDTO> map(List<Employee> employees);
|
||||||
|
|
||||||
|
default EmployeeFullNameDTO map(Employee employee) {
|
||||||
|
EmployeeFullNameDTO employeeInfoDTO = new EmployeeFullNameDTO();
|
||||||
|
employeeInfoDTO.setFullName(employee.getFirstName() + " " + employee.getLastName());
|
||||||
|
|
||||||
|
return employeeInfoDTO;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface EmployeeMapper {
|
||||||
|
|
||||||
|
List<EmployeeDTO> map(List<Employee> employees);
|
||||||
|
|
||||||
|
Set<EmployeeDTO> map(Set<Employee> employees);
|
||||||
|
|
||||||
|
Map<String, EmployeeDTO> map(Map<String, Employee> idEmployeeMap);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Company {
|
||||||
|
|
||||||
|
private List<Employee> employees;
|
||||||
|
|
||||||
|
public List<Employee> getEmployees() {
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployees(List<Employee> employees) {
|
||||||
|
this.employees = employees;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.model;
|
||||||
|
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
public Employee(String firstName, String lastName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class CompanyMapperAdderPreferredUnitTest {
|
||||||
|
|
||||||
|
private CompanyMapperAdderPreferred companyMapper = Mappers.getMapper(CompanyMapperAdderPreferred.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToCompanyDTO_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
Company company = new Company();
|
||||||
|
company.setEmployees(Collections.singletonList(employee));
|
||||||
|
|
||||||
|
CompanyDTO result = companyMapper.map(company);
|
||||||
|
|
||||||
|
List<EmployeeDTO> employees = result.getEmployees();
|
||||||
|
assertThat(employees).hasSize(1);
|
||||||
|
assertThat(employees.get(0).getFirstName()).isEqualTo("John");
|
||||||
|
assertThat(employees.get(0).getLastName()).isEqualTo("Doe");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class CompanyMapperUnitTest {
|
||||||
|
|
||||||
|
private CompanyMapper companyMapper = Mappers.getMapper(CompanyMapper.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToCompanyDTO_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
Company company = new Company();
|
||||||
|
company.setEmployees(Collections.singletonList(employee));
|
||||||
|
|
||||||
|
CompanyDTO result = companyMapper.map(company);
|
||||||
|
|
||||||
|
List<EmployeeDTO> employees = result.getEmployees();
|
||||||
|
assertThat(employees).hasSize(1);
|
||||||
|
assertThat(employees.get(0).getFirstName()).isEqualTo("John");
|
||||||
|
assertThat(employees.get(0).getLastName()).isEqualTo("Doe");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeFullNameDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class EmployeeFullNameMapperUnitTest {
|
||||||
|
|
||||||
|
private EmployeeFullNameMapper employeeMapper = Mappers.getMapper(EmployeeFullNameMapper.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToEmployeeFullNameDTOList_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
|
||||||
|
List<EmployeeFullNameDTO> result = employeeMapper.map(Collections.singletonList(employee));
|
||||||
|
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
assertThat(result.get(0).getFullName()).isEqualTo("John Doe");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||||
|
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||||
|
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class EmployeeMapperUnitTest {
|
||||||
|
|
||||||
|
private EmployeeMapper employeeMapper = Mappers.getMapper(EmployeeMapper.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToEmployeeDTOList_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
|
||||||
|
List<EmployeeDTO> result = employeeMapper.map(Collections.singletonList(employee));
|
||||||
|
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
assertThat(result.get(0).getFirstName()).isEqualTo("John");
|
||||||
|
assertThat(result.get(0).getLastName()).isEqualTo("Doe");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToEmployeeDTOSet_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
|
||||||
|
Set<EmployeeDTO> result = employeeMapper.map(Collections.singleton(employee));
|
||||||
|
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
assertThat(result.iterator().next().getFirstName()).isEqualTo("John");
|
||||||
|
assertThat(result.iterator().next().getLastName()).isEqualTo("Doe");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenMappingToEmployeeDTOMap_thenExpectCorrectMappingResult() {
|
||||||
|
Employee employee = new Employee("John", "Doe");
|
||||||
|
|
||||||
|
Map<String, EmployeeDTO> result = employeeMapper.map(Collections.singletonMap("1", employee));
|
||||||
|
|
||||||
|
assertThat(result).hasSize(1);
|
||||||
|
assertThat(result.get("1").getFirstName()).isEqualTo("John");
|
||||||
|
assertThat(result.get("1").getLastName()).isEqualTo("Doe");
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,11 +10,11 @@
|
||||||
<description>Sample R2DBC Project</description>
|
<description>Sample R2DBC Project</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>2.1.6.RELEASE</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -19,7 +19,7 @@ import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
public class R2dbcExampleApplicationTests {
|
public class R2dbcExampleApplicationIntegrationTest {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
|
@ -1,25 +0,0 @@
|
||||||
package com.baeldung.properties.yamlmap.factory;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
|
||||||
import org.springframework.core.env.PropertySource;
|
|
||||||
import org.springframework.core.io.support.EncodedResource;
|
|
||||||
import org.springframework.core.io.support.PropertySourceFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class YamlPropertySourceFactory implements PropertySourceFactory {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropertySource<?> createPropertySource(String name, EncodedResource encodedResource) throws IOException {
|
|
||||||
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
|
|
||||||
factory.setResources(encodedResource.getResource());
|
|
||||||
|
|
||||||
Properties properties = factory.getObject();
|
|
||||||
|
|
||||||
return new PropertiesPropertySource(encodedResource.getResource()
|
|
||||||
.getFilename(), properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,13 +4,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.baeldung.properties.yamlmap.factory.YamlPropertySourceFactory;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@PropertySource(value = "classpath:server.yml", factory = YamlPropertySourceFactory.class)
|
|
||||||
@ConfigurationProperties(prefix = "server")
|
@ConfigurationProperties(prefix = "server")
|
||||||
public class ServerProperties {
|
public class ServerProperties {
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-snapshots</id>
|
<id>spring-release</id>
|
||||||
<name>Spring Snapshots</name>
|
<name>Spring Release</name>
|
||||||
<url>https://repo.spring.io/libs-snapshot</url>
|
<url>https://repo.spring.io/release</url>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
<enabled>true</enabled>
|
<enabled>false</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
|
@ -8,9 +8,10 @@
|
||||||
<description>Simple Spring Cloud Stream</description>
|
<description>Simple Spring Cloud Stream</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>2.1.5.RELEASE</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
<name>spring-cloud-stream-kinesis</name>
|
<name>spring-cloud-stream-kinesis</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>2.1.8.RELEASE</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath/>
|
<relativePath>../../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<structurizr.version>1.0.0-RC5</structurizr.version>
|
<structurizr.version>1.0.0</structurizr.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -2,6 +2,8 @@ package com.baeldung.structurizr;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.structurizr.Workspace;
|
import com.structurizr.Workspace;
|
||||||
import com.structurizr.analysis.ComponentFinder;
|
import com.structurizr.analysis.ComponentFinder;
|
||||||
|
@ -40,16 +42,32 @@ public class StructurizrSimple {
|
||||||
addContainers(workspace);
|
addContainers(workspace);
|
||||||
addComponents(workspace);
|
addComponents(workspace);
|
||||||
addSpringComponents(workspace);
|
addSpringComponents(workspace);
|
||||||
exportToPlantUml(workspace.getViews().getViewWithKey(SOFTWARE_SYSTEM_VIEW));
|
exportToPlantUml(findViewWithKey(workspace.getViews(), SOFTWARE_SYSTEM_VIEW));
|
||||||
exportToPlantUml(workspace.getViews().getViewWithKey(CONTAINER_VIEW));
|
exportToPlantUml(findViewWithKey(workspace.getViews(), CONTAINER_VIEW));
|
||||||
exportToPlantUml(workspace.getViews().getViewWithKey(COMPONENT_VIEW));
|
exportToPlantUml(findViewWithKey(workspace.getViews(), COMPONENT_VIEW));
|
||||||
|
|
||||||
exportToPlantUml(workspace.getViews().getViewWithKey(JVM2_COMPONENT_VIEW));
|
exportToPlantUml(findViewWithKey(workspace.getViews(), JVM2_COMPONENT_VIEW));
|
||||||
|
|
||||||
addStyles(workspace.getViews());
|
addStyles(workspace.getViews());
|
||||||
//uploadToExternal(workspace);
|
//uploadToExternal(workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static View findViewWithKey(ViewSet viewSet, String key) {
|
||||||
|
if (key == null) {
|
||||||
|
throw new IllegalArgumentException("A key must be specified.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<View> views = new HashSet<>();
|
||||||
|
views.addAll(viewSet.getSystemLandscapeViews());
|
||||||
|
views.addAll(viewSet.getSystemContextViews());
|
||||||
|
views.addAll(viewSet.getContainerViews());
|
||||||
|
views.addAll(viewSet.getComponentViews());
|
||||||
|
views.addAll(viewSet.getDynamicViews());
|
||||||
|
views.addAll(viewSet.getDeploymentViews());
|
||||||
|
|
||||||
|
return views.stream().filter(v -> key.equals(v.getKey())).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
private static void addSpringComponents(Workspace workspace) throws Exception {
|
private static void addSpringComponents(Workspace workspace) throws Exception {
|
||||||
Container jvm2 = workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL).getContainerWithName("JVM-2");
|
Container jvm2 = workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL).getContainerWithName("JVM-2");
|
||||||
findComponents(jvm2);
|
findComponents(jvm2);
|
||||||
|
|
Loading…
Reference in New Issue