├── src ├── main │ ├── resources │ │ ├── application.properties │ │ └── db │ │ │ └── migration │ │ │ └── V0__teams.sql │ └── java │ │ └── dev │ │ └── aleixmorgadas │ │ └── thinportsandadapters │ │ ├── domain │ │ ├── TeamData.java │ │ ├── TeamRepository.java │ │ ├── Team.java │ │ └── TeamService.java │ │ ├── ThinPAApplication.java │ │ └── web │ │ └── TeamController.java └── test │ └── java │ └── dev │ └── aleixmorgadas │ └── thinportsandadapters │ ├── ThinPAApplicationTests.java │ ├── domain │ ├── TeamTest.java │ ├── TeamServiceIntegrationTest.java │ ├── TeamServiceTest.java │ └── TeamRepositoryIntegrationTest.java │ ├── TestThinPAApplication.java │ ├── AbstractIntegrationTest.java │ └── web │ ├── TeamControllerUnitTest.java │ ├── TeamControllerE2ETest.java │ └── TeamControllerIntegrationTest.java ├── settings.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── LICENSE ├── .github ├── workflows │ └── gradle.yml └── assets │ └── hexagonal.svg ├── gradlew.bat ├── README.md └── gradlew /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "thin-ports-and-adapters" 2 | -------------------------------------------------------------------------------- /src/main/resources/db/migration/V0__teams.sql: -------------------------------------------------------------------------------- 1 | create table teams( 2 | id uuid primary key, 3 | name varchar(100) not null 4 | ); -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aleixmorgadas/thin-ports-and-adapters/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamData.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | public record TeamData(String id, String name) { 4 | } 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/ThinPAApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | class ThinPAApplicationTests extends AbstractIntegrationTest { 6 | 7 | @Test 8 | void contextLoads() { 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamRepository.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import org.springframework.data.repository.ListCrudRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.UUID; 7 | 8 | @Repository 9 | public interface TeamRepository extends ListCrudRepository { 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/ThinPAApplication.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ThinPAApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ThinPAApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | out/ 26 | !**/src/main/**/out/ 27 | !**/src/test/**/out/ 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | 36 | ### VS Code ### 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.util.UUID; 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | class TeamTest { 10 | 11 | @Test 12 | void createTeam() { 13 | Team team = new Team(UUID.randomUUID(), "Benefits Team"); 14 | assertEquals("Benefits Team", team.name()); 15 | } 16 | 17 | @Test 18 | void renameTeam() { 19 | Team team = new Team(UUID.randomUUID(), "Benefits Team"); 20 | team.rename("New Benefits Team"); 21 | assertEquals("New Benefits Team", team.name()); 22 | } 23 | } -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import dev.aleixmorgadas.thinportsandadapters.AbstractIntegrationTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | 9 | public class TeamServiceIntegrationTest extends AbstractIntegrationTest { 10 | @Autowired 11 | private TeamService teamService; 12 | 13 | @Test 14 | void createTeam() { 15 | TeamData teamData = teamService.createTeam("Benefits Team"); 16 | assertThat("Benefits Team").isEqualTo(teamData.name()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/domain/Team.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.ToString; 5 | 6 | import java.util.UUID; 7 | 8 | 9 | @Entity(name = "teams") 10 | @ToString 11 | class Team { 12 | @Id 13 | private UUID id; 14 | private String name; 15 | 16 | public Team(UUID id, String name) { 17 | this.id = id; 18 | this.name = name; 19 | } 20 | 21 | public Team() { 22 | } 23 | 24 | public UUID id() { 25 | return id; 26 | } 27 | 28 | public String name() { 29 | return name; 30 | } 31 | 32 | public void rename(String name) { 33 | this.name = name; 34 | } 35 | } -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/TestThinPAApplication.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.test.context.TestConfiguration; 5 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 6 | import org.springframework.context.annotation.Bean; 7 | import org.testcontainers.containers.PostgreSQLContainer; 8 | import org.testcontainers.utility.DockerImageName; 9 | 10 | @TestConfiguration(proxyBeanMethods = false) 11 | public class TestThinPAApplication { 12 | 13 | @Bean 14 | @ServiceConnection 15 | PostgreSQLContainer postgresContainer() { 16 | return new PostgreSQLContainer<>(DockerImageName.parse("postgres:latest")); 17 | } 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.from(ThinPAApplication::main).with(TestThinPAApplication.class).run(args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Aleix Morgadas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamServiceTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import org.junit.jupiter.api.BeforeAll; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.TestInstance; 6 | 7 | import java.util.UUID; 8 | 9 | import static org.junit.jupiter.api.Assertions.*; 10 | import static org.mockito.ArgumentMatchers.any; 11 | import static org.mockito.Mockito.mock; 12 | import static org.mockito.Mockito.when; 13 | 14 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 15 | class TeamServiceTest { 16 | private TeamRepository teamRepository; 17 | 18 | @BeforeAll 19 | void setup() { 20 | teamRepository = mock(TeamRepository.class); 21 | } 22 | 23 | @Test 24 | void createTeam() { 25 | var id = UUID.randomUUID(); 26 | when(teamRepository.save(any())).thenReturn(new Team(id, "Benefits Team")); 27 | 28 | TeamService teamService = new TeamService(teamRepository); 29 | TeamData teamData = teamService.createTeam("Benefits Team"); 30 | assertEquals("Benefits Team", teamData.name()); 31 | } 32 | } -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamRepositoryIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import dev.aleixmorgadas.thinportsandadapters.AbstractIntegrationTest; 4 | import org.junit.jupiter.api.*; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | 7 | import java.util.UUID; 8 | 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 12 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 13 | public class TeamRepositoryIntegrationTest extends AbstractIntegrationTest { 14 | @Autowired 15 | private TeamRepository teamRepository; 16 | 17 | @AfterAll 18 | void tearDown() { 19 | teamRepository.deleteAll(); 20 | } 21 | 22 | @Test 23 | void saveTeam() { 24 | var id = UUID.randomUUID(); 25 | var team = new Team(id,"Benefits Team"); 26 | teamRepository.save(team); 27 | 28 | var foundTeam = teamRepository.findById(id); 29 | assertThat(foundTeam).isPresent(); 30 | assertThat(foundTeam.get().name()).isEqualTo("Benefits Team"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle 7 | 8 | name: Java CI with Gradle 9 | 10 | on: 11 | push: 12 | branches: [ "main" ] 13 | pull_request: 14 | branches: [ "main" ] 15 | 16 | jobs: 17 | build: 18 | 19 | runs-on: ubuntu-latest 20 | permissions: 21 | contents: read 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Set up JDK 21 26 | uses: actions/setup-java@v4 27 | with: 28 | java-version: '21' 29 | distribution: 'temurin' 30 | cache: gradle 31 | 32 | # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. 33 | # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md 34 | - name: Setup Gradle 35 | uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 36 | 37 | - name: Build with Gradle Wrapper 38 | run: ./gradlew build 39 | 40 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.DynamicPropertyRegistry; 9 | import org.springframework.test.context.DynamicPropertySource; 10 | import org.springframework.test.web.servlet.MockMvc; 11 | import org.testcontainers.containers.PostgreSQLContainer; 12 | import org.testcontainers.utility.DockerImageName; 13 | 14 | @SpringBootTest 15 | @AutoConfigureMockMvc 16 | public class AbstractIntegrationTest { 17 | @Autowired 18 | protected MockMvc mockMvc; 19 | 20 | static PostgreSQLContainer postgres = new PostgreSQLContainer<>(DockerImageName.parse("postgres:latest")); 21 | 22 | static { 23 | postgres.start(); 24 | } 25 | 26 | @DynamicPropertySource 27 | static void configureProperties(DynamicPropertyRegistry registry) { 28 | registry.add("spring.datasource.url", postgres::getJdbcUrl); 29 | registry.add("spring.datasource.username", postgres::getUsername); 30 | registry.add("spring.datasource.password", postgres::getPassword); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/web/TeamController.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.web; 2 | 3 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamData; 4 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamService; 5 | import lombok.AllArgsConstructor; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import java.util.List; 10 | 11 | @RestController 12 | @RequestMapping(TeamController.URI) 13 | @AllArgsConstructor 14 | public class TeamController { 15 | public static final String URI = "/teams"; 16 | private final TeamService teamService; 17 | 18 | @PostMapping 19 | public ResponseEntity createTeam(@RequestBody TeamRequest teamRequest) { 20 | var team = teamService.createTeam(teamRequest.name()); 21 | return ResponseEntity.ok(team); 22 | } 23 | 24 | @GetMapping 25 | public ResponseEntity> seeAllTeams() { 26 | return ResponseEntity.ok(teamService.seeAllTeams()); 27 | } 28 | 29 | @PatchMapping("/{id}/rename") 30 | public ResponseEntity renameTeam( 31 | @PathVariable String id, 32 | @RequestBody TeamRequest teamRequest) { 33 | var team = teamService.renameTeam(id, teamRequest.name()); 34 | return ResponseEntity.ok(team); 35 | } 36 | 37 | public record TeamRequest(String name) { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamService.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.domain; 2 | 3 | import jakarta.transaction.Transactional; 4 | import lombok.AllArgsConstructor; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | import java.util.UUID; 9 | 10 | @Service 11 | @AllArgsConstructor 12 | @Transactional 13 | public class TeamService { 14 | private final TeamRepository teamRepository; 15 | 16 | public TeamData createTeam(String name) { 17 | Team team = teamRepository.save(new Team(UUID.randomUUID(), name)); 18 | return new TeamData(team.id().toString(), team.name()); 19 | } 20 | 21 | public List seeAllTeams() { 22 | return teamRepository.findAll() 23 | .stream() 24 | .map(team -> new TeamData(team.id().toString(), team.name())) 25 | .toList(); 26 | } 27 | 28 | public TeamData renameTeam(String id, String name) { 29 | var team = teamRepository.findById(UUID.fromString(id)) 30 | .orElseThrow(() -> new IllegalArgumentException("Team not found")); 31 | team.rename(name); 32 | return new TeamData(team.id().toString(), team.name()); 33 | } 34 | 35 | public TeamData getTeam(String id) { 36 | var team = teamRepository.findById(UUID.fromString(id)) 37 | .orElseThrow(() -> new IllegalArgumentException("Team not found")); 38 | return new TeamData(team.id().toString(), team.name()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerUnitTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.web; 2 | 3 | 4 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamData; 5 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamService; 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.TestInstance; 9 | import org.springframework.http.HttpStatus; 10 | 11 | import java.util.UUID; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | import static org.junit.jupiter.api.Assertions.assertNotNull; 15 | import static org.mockito.Mockito.mock; 16 | import static org.mockito.Mockito.when; 17 | 18 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 19 | public class TeamControllerUnitTest { 20 | private TeamController teamController; 21 | private TeamService teamService; 22 | 23 | @BeforeAll 24 | public void setUp() { 25 | teamService = mock(TeamService.class); 26 | teamController = new TeamController(teamService); 27 | } 28 | 29 | @Test 30 | public void createTeam() { 31 | when(teamService.createTeam("Benefits Team")) 32 | .thenReturn(new TeamData(UUID.randomUUID().toString(), "Benefits Team")); 33 | 34 | var response = teamController.createTeam(new TeamController.TeamRequest("Benefits Team")); 35 | assertNotNull(response); 36 | assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); 37 | assertThat(response.getBody().name()).isEqualTo("Benefits Team"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerE2ETest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.web; 2 | 3 | import com.jayway.jsonpath.JsonPath; 4 | import dev.aleixmorgadas.thinportsandadapters.AbstractIntegrationTest; 5 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamRepository; 6 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamService; 7 | import org.junit.jupiter.api.*; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.MediaType; 10 | 11 | import java.util.UUID; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; 15 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 16 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 17 | 18 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 19 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 20 | class TeamControllerE2ETest extends AbstractIntegrationTest { 21 | @Autowired 22 | private TeamRepository teamRepository; 23 | @Autowired 24 | private TeamService teamService; 25 | 26 | private UUID teamId; 27 | 28 | @AfterAll 29 | void tearDown() { 30 | teamRepository.deleteAll(); 31 | } 32 | 33 | @Test 34 | @Order(1) 35 | void createTeam() throws Exception { 36 | var response = mockMvc.perform(post("/teams") 37 | .contentType(MediaType.APPLICATION_JSON) 38 | .content("{\"name\": \"Benefits Team\"}")) 39 | .andExpect(status().isOk()) 40 | .andExpect(jsonPath("$.name").value("Benefits Team")) 41 | .andReturn(); 42 | 43 | // Extract the teamId from the response for later use 44 | teamId = UUID.fromString(JsonPath.read(response.getResponse().getContentAsString(), "$.id")); 45 | } 46 | 47 | @Test 48 | @Order(2) 49 | void seeAllTeams() throws Exception { 50 | mockMvc.perform(get("/teams") 51 | .contentType(MediaType.APPLICATION_JSON)) 52 | .andExpect(status().isOk()) 53 | .andExpect(jsonPath("$[0].name").value("Benefits Team")); 54 | } 55 | 56 | @Test 57 | @Order(3) 58 | void renameTeam() throws Exception { 59 | var response = mockMvc.perform(patch("/teams/" + teamId + "/rename") 60 | .contentType(MediaType.APPLICATION_JSON) 61 | .content("{\"name\": \"New Benefits Team\"}")) 62 | .andExpect(status().isOk()) 63 | .andExpect(jsonPath("$.name").value("New Benefits Team")) 64 | .andReturn(); 65 | 66 | // Extract the teamId from the response for later use 67 | var teamId = (String) JsonPath.read(response.getResponse().getContentAsString(), "$.id"); 68 | 69 | assertThat(teamService.getTeam(teamId).name()) 70 | .withFailMessage("Team name not updated") 71 | .isEqualTo("New Benefits Team"); 72 | } 73 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package dev.aleixmorgadas.thinportsandadapters.web; 2 | 3 | import com.jayway.jsonpath.JsonPath; 4 | import dev.aleixmorgadas.thinportsandadapters.AbstractIntegrationTest; 5 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamData; 6 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamRepository; 7 | import dev.aleixmorgadas.thinportsandadapters.domain.TeamService; 8 | import org.junit.jupiter.api.*; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.mock.mockito.MockBean; 11 | import org.springframework.http.MediaType; 12 | 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | import static org.mockito.Mockito.when; 18 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 20 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 21 | 22 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 23 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 24 | class TeamControllerIntegrationTest extends AbstractIntegrationTest { 25 | @MockBean 26 | private TeamService teamService; 27 | 28 | private UUID teamId; 29 | 30 | @Test 31 | @Order(1) 32 | void createTeam() throws Exception { 33 | when(teamService.createTeam("Benefits Team")) 34 | .thenReturn(new TeamData(UUID.randomUUID().toString(), "Benefits Team")); 35 | 36 | var response = mockMvc.perform(post("/teams") 37 | .contentType(MediaType.APPLICATION_JSON) 38 | .content("{\"name\": \"Benefits Team\"}")) 39 | .andExpect(status().isOk()) 40 | .andExpect(jsonPath("$.name").value("Benefits Team")) 41 | .andReturn(); 42 | 43 | // Extract the teamId from the response for later use 44 | teamId = UUID.fromString(JsonPath.read(response.getResponse().getContentAsString(), "$.id")); 45 | } 46 | 47 | @Test 48 | @Order(2) 49 | void seeAllTeams() throws Exception { 50 | when(teamService.seeAllTeams()) 51 | .thenReturn(List.of(new TeamData(teamId.toString(), "Benefits Team"))); 52 | 53 | mockMvc.perform(get("/teams") 54 | .contentType(MediaType.APPLICATION_JSON)) 55 | .andExpect(status().isOk()) 56 | .andExpect(jsonPath("$[0].name").value("Benefits Team")); 57 | } 58 | 59 | @Test 60 | @Order(3) 61 | void renameTeam() throws Exception { 62 | when(teamService.renameTeam(teamId.toString(), "New Benefits Team")) 63 | .thenReturn(new TeamData(teamId.toString(), "New Benefits Team")); 64 | 65 | mockMvc.perform(patch("/teams/" + teamId + "/rename") 66 | .contentType(MediaType.APPLICATION_JSON) 67 | .content("{\"name\": \"New Benefits Team\"}")) 68 | .andExpect(status().isOk()) 69 | .andExpect(jsonPath("$.name").value("New Benefits Team")); 70 | } 71 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # thin-ports-and-adapters 2 | 3 | [![GitHub Discussions](https://img.shields.io/github/discussions/aleixmorgadas/thin-ports-and-adapters)](https://github.com/aleixmorgadas/thin-ports-and-adapters/discussions) 4 | 5 | ### [Share your thin ports and adapters in another language or framework here! 🙌](https://github.com/aleixmorgadas/thin-ports-and-adapters/discussions/categories/thin-p-a-in-other-languages-and-frameworks) 6 | 7 | This is an example of a Ports and Adapters (P&A for short) architecture in Java 21 and Spring Boot. 8 | 9 | We can define a simple P&A architecture as follows: 10 | 11 | ```mermaid 12 | graph LR 13 | RestControllerAdapter --> ApplicationService 14 | ApplicationService --> Entity 15 | Entity --> RepositoryPort 16 | RepositoryPort --> RepositorySQLAdapter 17 | subgraph Outside 18 | RestControllerAdapter 19 | RepositorySQLAdapter 20 | end 21 | subgraph Inside 22 | ApplicationService 23 | Entity 24 | RepositoryPort 25 | end 26 | 27 | PAdapter(Primary Adapter) -.-> RestControllerAdapter 28 | PPort(Primary Port) -.-> ApplicationService 29 | SAdapter(Secondary Adapter) -.-> RepositorySQLAdapter 30 | SPort(Secondary Port) -.-> RepositoryPort 31 | ``` 32 | 33 | ![ports and adapters example](./.github/assets/hexagonal.svg) 34 | [Reference](https://codesoapbox.dev/ports-adapters-aka-hexagonal-architecture-explained/) 35 | 36 | A possible Spring Boot implementation of the adapters is: 37 | 38 | ```java 39 | // RestControllerAdapter (Primary Adapter) 40 | @RestController 41 | class TeamController { 42 | private final TeamService teamService; // Primary Port 43 | 44 | @GetMapping("/teams") 45 | public List getTeams() { 46 | return teamService.getTeams(); 47 | } 48 | } 49 | 50 | // TeamRepositoryPort (Secondary Port) 51 | interface TeamRepository extends ListCrudRepository { 52 | } 53 | 54 | // The SQL Adapter of the TeamRepositoryPort is provided by Spring Data JPA. It is the Secondary Adapter. 55 | ``` 56 | 57 | ### Is it only this? 58 | 59 | Yes, a ports and adapters architecture is only this. 60 | 61 | Patterns like Domain Events, Aggregates, Value Objects, CQRS and Event Sourcing, all those patters go beyond the intention or responsibility of a ports and adapters architecture. Indeed, a P&A architecture works well with CRUD models (or models with not many domain logic) as well as Domain Models. 62 | 63 | The beauty of it is that it adapts to each part of your business, and you can choose the right amount of abstraction/complexity for each scenario. 64 | 65 | ### And testing? 66 | 67 | IMHO, this is where a P&A shines. It really helps you create a solid and adaptable test suite. Here a short example of test types. 68 | 69 | **End-to-end tests** 70 | 71 | - [TeamControllerE2ETest](src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerE2ETest.java) 72 | 73 | **Integration test** 74 | 75 | - HTTP adapter. [TeamControllerIntegrationTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerIntegrationTest.java) 76 | - Service and SQL Repository. [TeamServiceIntegrationTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamServiceIntegrationTest.java) 77 | - SQL Repository. [TeamRepositoryIntegrationTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamRepositoryIntegrationTest.java) 78 | 79 | **Unit test** 80 | 81 | - HTTP adapter. [TeamControllerUnitTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/web/TeamControllerUnitTest.java) 82 | - Service. [TeamServiceTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamServiceTest.java) 83 | - Domain. [TeamTest](https://github.com/aleixmorgadas/thin-ports-and-adapters/blob/main/src/test/java/dev/aleixmorgadas/thinportsandadapters/domain/TeamTest.java) 84 | 85 | ## Running the application 86 | 87 | ```shell 88 | ./gradlew bootTestRun 89 | ``` 90 | 91 | ℹ️ It uses [Spring Boot integration][sbit] with Testcontainers to spin up a PostgreSQL container. 92 | 93 | ### Using the API 94 | 95 | ```shell 96 | curl -X GET http://localhost:8080/teams 97 | ``` 98 | 99 | ```shell 100 | curl -X POST -H "Content-Type: application/json" -d '{"name": "Team 1"}' http://localhost:8080/teams 101 | ``` 102 | 103 | ```shell 104 | curl -X PATCH -H "Content-Type: application/json" -d '{"name": "Team 1"}' http://localhost:8080/teams/{id}/rename 105 | ``` 106 | 107 | ## Running the tests 108 | 109 | ```shell 110 | ./gradlew test 111 | ``` 112 | 113 | You will see how the thin ports and adapters architecture allows us to test the application with multiple approaches: 114 | 115 | - Unit tests for the domain logic. 116 | - Integration tests for the application service. 117 | - End-to-end tests for the REST API. 118 | 119 | [sbit]: https://spring.io/blog/2023/06/23/improved-testcontainers-support-in-spring-boot-3-1 120 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /.github/assets/hexagonal.svg: -------------------------------------------------------------------------------- 1 | 2 | 11 | 13 | 15 | 17 | 19 | 22 | 23 | 25 | 28 | 29 | 31 | 34 | 35 | 37 | 40 | 41 | 43 | 46 | 47 | 49 | 52 | 53 | 55 | 58 | 59 | 61 | 64 | 65 | 67 | 70 | 71 | 73 | 76 | 77 | 79 | 81 | 84 | 85 | 87 | 90 | 91 | 93 | 96 | 97 | 99 | 102 | 103 | 105 | 108 | 109 | 111 | 114 | 115 | 117 | 120 | 121 | 123 | 126 | 127 | 129 | 132 | 133 | 135 | 137 | 140 | 141 | 143 | 146 | 147 | 149 | 152 | 153 | 155 | 158 | 159 | 161 | 163 | 166 | 167 | 169 | 172 | 173 | 175 | 178 | 179 | 181 | 184 | 185 | 187 | 190 | 191 | 193 | 196 | 197 | 199 | 202 | 203 | 205 | 208 | 209 | 211 | 214 | 215 | 217 | 220 | 221 | 223 | 226 | 227 | 229 | 232 | 233 | 235 | 238 | 239 | 241 | 244 | 245 | 247 | 250 | 251 | 253 | 256 | 257 | 259 | 262 | 263 | 265 | 268 | 269 | 271 | 274 | 275 | 277 | 280 | 281 | 283 | 285 | 287 | 290 | 291 | 293 | 296 | 297 | 299 | 302 | 303 | 305 | 308 | 309 | 311 | 314 | 315 | 317 | 320 | 321 | 323 | 326 | 327 | 329 | 332 | 333 | 335 | 338 | 339 | 341 | 344 | 345 | 347 | 350 | 351 | 353 | 356 | 357 | 359 | 362 | 363 | 365 | 368 | 369 | 371 | 374 | 375 | 377 | 380 | 381 | 383 | 386 | 387 | 389 | 392 | 393 | 395 | 398 | 399 | 401 | 404 | 405 | 407 | 410 | 411 | 413 | 416 | 417 | 419 | 422 | 423 | 425 | 427 | 430 | 431 | 433 | 435 | 438 | 439 | 441 | 444 | 445 | 447 | 450 | 451 | 453 | 456 | 457 | 459 | 462 | 463 | 465 | 468 | 469 | 471 | 474 | 475 | 477 | 480 | 481 | 483 | 486 | 487 | 489 | 492 | 493 | 495 | 498 | 499 | 501 | 504 | 505 | 507 | 510 | 511 | 513 | 516 | 517 | 519 | 522 | 523 | 525 | 528 | 529 | 531 | 534 | 535 | 537 | 540 | 541 | 543 | 546 | 547 | 549 | 552 | 553 | 555 | 557 | 560 | 561 | 563 | 566 | 567 | 569 | 572 | 573 | 575 | 578 | 579 | 581 | 584 | 585 | 587 | 590 | 591 | 593 | 596 | 597 | 599 | 602 | 603 | 605 | 608 | 609 | 611 | 613 | 616 | 617 | 619 | 622 | 623 | 625 | 628 | 629 | 630 | 632 | 636 | 637 | 638 | 641 | 647 | 648 | 654 | 660 | 666 | 672 | 683 | 694 | 698 | 703 | 708 | 713 | 718 | 723 | 728 | 733 | 734 | 738 | 743 | 748 | 753 | 758 | 763 | 768 | 773 | 778 | 783 | 788 | 793 | 798 | 803 | 808 | 813 | 818 | 823 | 828 | 833 | 838 | 843 | 848 | 853 | 858 | 859 | 863 | 868 | 873 | 878 | 883 | 888 | 893 | 898 | 903 | 908 | 913 | 918 | 923 | 928 | 933 | 938 | 943 | 948 | 953 | 958 | 963 | 968 | 973 | 978 | 983 | 988 | 989 | 1000 | 1013 | 1026 | 1030 | 1035 | 1036 | 1040 | 1045 | 1050 | 1055 | 1060 | 1065 | 1070 | 1075 | 1080 | 1081 | 1094 | 1098 | 1103 | 1108 | 1113 | 1118 | 1123 | 1128 | 1133 | 1138 | 1143 | 1148 | 1149 | 1162 | 1166 | 1171 | 1176 | 1181 | 1186 | 1191 | 1196 | 1201 | 1206 | 1211 | 1216 | 1221 | 1226 | 1231 | 1236 | 1241 | 1242 | 1255 | 1259 | 1264 | 1269 | 1274 | 1279 | 1284 | 1289 | 1294 | 1299 | 1304 | 1309 | 1314 | 1319 | 1324 | 1325 | 1336 | 1349 | 1360 | 1373 | 1384 | 1397 | 1410 | 1414 | 1419 | 1424 | 1429 | 1434 | 1439 | 1444 | 1449 | 1454 | 1455 | 1459 | 1464 | 1469 | 1474 | 1479 | 1484 | 1489 | 1494 | 1499 | 1504 | 1509 | 1514 | 1519 | 1524 | 1525 | 1538 | 1542 | 1547 | 1552 | 1557 | 1562 | 1567 | 1572 | 1577 | 1582 | 1587 | 1592 | 1597 | 1598 | 1602 | 1607 | 1608 | 1612 | 1617 | 1622 | 1627 | 1632 | 1637 | 1642 | 1647 | 1652 | 1657 | 1662 | 1667 | 1672 | 1673 | 1686 | 1690 | 1695 | 1700 | 1705 | 1710 | 1715 | 1720 | 1725 | 1726 | 1730 | 1735 | 1736 | 1740 | 1745 | 1750 | 1755 | 1760 | 1765 | 1770 | 1775 | 1780 | 1785 | 1790 | 1795 | 1796 | 1800 | 1805 | 1810 | 1815 | 1820 | 1825 | 1830 | 1835 | 1840 | 1845 | 1850 | 1855 | 1860 | 1865 | 1870 | 1875 | 1880 | 1885 | 1890 | 1895 | 1900 | 1905 | 1910 | 1915 | 1920 | 1921 | 1925 | 1930 | 1935 | 1940 | 1945 | 1950 | 1955 | 1960 | 1965 | 1970 | 1975 | 1980 | 1985 | 1990 | 1995 | 2000 | 2005 | 2010 | 2015 | 2020 | 2025 | 2030 | 2035 | 2040 | 2045 | 2050 | 2055 | 2060 | 2065 | 2070 | 2075 | 2080 | 2085 | 2090 | 2095 | 2100 | 2105 | 2110 | 2115 | 2120 | 2125 | 2130 | 2135 | 2140 | 2145 | 2150 | 2155 | 2160 | 2161 | 2172 | 2185 | 2196 | 2209 | 2220 | 2233 | 2237 | 2242 | 2247 | 2252 | 2257 | 2262 | 2267 | 2272 | 2277 | 2282 | 2287 | 2292 | 2297 | 2302 | 2307 | 2312 | 2317 | 2322 | 2327 | 2332 | 2337 | 2342 | 2347 | 2352 | 2357 | 2362 | 2367 | 2372 | 2377 | 2382 | 2387 | 2392 | 2397 | 2402 | 2407 | 2412 | 2417 | 2422 | 2427 | 2432 | 2437 | 2442 | 2447 | 2452 | 2457 | 2462 | 2467 | 2472 | 2477 | 2482 | 2487 | 2492 | 2497 | 2498 | 2511 | 2515 | 2520 | 2525 | 2530 | 2535 | 2540 | 2545 | 2550 | 2555 | 2560 | 2565 | 2570 | 2575 | 2580 | 2581 | 2585 | 2590 | 2591 | 2595 | 2600 | 2605 | 2610 | 2615 | 2620 | 2625 | 2630 | 2635 | 2640 | 2645 | 2650 | 2651 | 2662 | 2675 | 2686 | 2699 | 2705 | 2709 | 2714 | 2719 | 2724 | 2729 | 2734 | 2739 | 2744 | 2749 | 2754 | 2759 | 2764 | 2769 | 2774 | 2779 | 2784 | 2789 | 2790 | 2791 | --------------------------------------------------------------------------------