Skip to content

Commit ccc1ec9

Browse files
committed
Add readme and class diagram
1 parent 9b3aa78 commit ccc1ec9

File tree

8 files changed

+364
-10
lines changed

8 files changed

+364
-10
lines changed

hexagonal/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout: pattern
3+
title: Hexagonal Architecture
4+
folder: hexagonal
5+
permalink: /patterns/hexagonal/
6+
categories: Architectural
7+
tags:
8+
- Java
9+
- Difficulty-Expert
10+
---
11+
12+
## Intent
13+
Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.
14+
15+
![Hexagonal Architecture class diagram](./etc/hexagonal.png)
16+
17+
## Applicability
18+
Use Hexagonal Architecture pattern when
19+
20+
* it is important that the application is fully testable
21+
* you use Domain Driven Design methodology and/or Microservices architectural style
22+
23+
## Real world examples
24+
25+
* [Apache Isis](https://isis.apache.org/)
26+
27+
## Credits
28+
29+
* [Alistair Cockburn - Hexagonal Architecture](http://alistair.cockburn.us/Hexagonal+architecture)

hexagonal/etc/hexagonal.png

162 KB
Loading

hexagonal/etc/hexagonal.ucls

Lines changed: 325 additions & 0 deletions
Large diffs are not rendered by default.

hexagonal/src/main/java/com/iluwatar/hexagonal/administration/LotteryAdministrationImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.iluwatar.hexagonal.banking.WireTransfers;
2828
import com.iluwatar.hexagonal.banking.WireTransfersImpl;
2929
import com.iluwatar.hexagonal.database.LotteryTicketRepository;
30-
import com.iluwatar.hexagonal.database.LotteryTicketRepositoryMock;
30+
import com.iluwatar.hexagonal.database.LotteryTicketInMemoryRepository;
3131
import com.iluwatar.hexagonal.domain.LotteryConstants;
3232
import com.iluwatar.hexagonal.domain.LotteryNumbers;
3333
import com.iluwatar.hexagonal.domain.LotteryTicket;
@@ -55,7 +55,7 @@ public class LotteryAdministrationImpl implements LotteryAdministration {
5555
private final WireTransfers bank = new WireTransfersImpl();
5656

5757
public LotteryAdministrationImpl() {
58-
repository = new LotteryTicketRepositoryMock();
58+
repository = new LotteryTicketInMemoryRepository();
5959
}
6060

6161
@Override

hexagonal/src/main/java/com/iluwatar/hexagonal/database/LotteryTicketRepositoryMock.java renamed to hexagonal/src/main/java/com/iluwatar/hexagonal/database/LotteryTicketInMemoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* Mock database for lottery tickets.
3535
*
3636
*/
37-
public class LotteryTicketRepositoryMock implements LotteryTicketRepository {
37+
public class LotteryTicketInMemoryRepository implements LotteryTicketRepository {
3838

3939
private static Map<LotteryTicketId, LotteryTicket> tickets = new HashMap<>();
4040

hexagonal/src/main/java/com/iluwatar/hexagonal/service/LotteryServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.iluwatar.hexagonal.banking.WireTransfers;
2828
import com.iluwatar.hexagonal.banking.WireTransfersImpl;
2929
import com.iluwatar.hexagonal.database.LotteryTicketRepository;
30-
import com.iluwatar.hexagonal.database.LotteryTicketRepositoryMock;
30+
import com.iluwatar.hexagonal.database.LotteryTicketInMemoryRepository;
3131
import com.iluwatar.hexagonal.domain.LotteryConstants;
3232
import com.iluwatar.hexagonal.domain.LotteryNumbers;
3333
import com.iluwatar.hexagonal.domain.LotteryTicket;
@@ -51,7 +51,7 @@ public class LotteryServiceImpl implements LotteryService {
5151
private final LotteryNotifications notifications = new LotteryNotificationsImpl();
5252

5353
public LotteryServiceImpl() {
54-
repository = new LotteryTicketRepositoryMock();
54+
repository = new LotteryTicketInMemoryRepository();
5555
}
5656

5757
@Override

hexagonal/src/test/java/com/iluwatar/hexagonal/database/LotteryTicketRepositoryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.junit.Test;
3232

3333
import com.iluwatar.hexagonal.database.LotteryTicketRepository;
34-
import com.iluwatar.hexagonal.database.LotteryTicketRepositoryMock;
34+
import com.iluwatar.hexagonal.database.LotteryTicketInMemoryRepository;
3535
import com.iluwatar.hexagonal.domain.LotteryTicket;
3636
import com.iluwatar.hexagonal.domain.LotteryTicketId;
3737
import com.iluwatar.hexagonal.test.LotteryTestUtils;
@@ -43,7 +43,7 @@
4343
*/
4444
public class LotteryTicketRepositoryTest {
4545

46-
private final LotteryTicketRepository repository = new LotteryTicketRepositoryMock();
46+
private final LotteryTicketRepository repository = new LotteryTicketInMemoryRepository();
4747

4848
@Before
4949
public void clear() {
@@ -52,7 +52,7 @@ public void clear() {
5252

5353
@Test
5454
public void testCrudOperations() {
55-
LotteryTicketRepository repository = new LotteryTicketRepositoryMock();
55+
LotteryTicketRepository repository = new LotteryTicketInMemoryRepository();
5656
assertEquals(repository.findAll().size(), 0);
5757
LotteryTicket ticket = LotteryTestUtils.createLotteryTicket();
5858
Optional<LotteryTicketId> id = repository.save(ticket);

hexagonal/src/test/java/com/iluwatar/hexagonal/lottery/LotteryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import com.iluwatar.hexagonal.banking.WireTransfers;
3939
import com.iluwatar.hexagonal.banking.WireTransfersImpl;
4040
import com.iluwatar.hexagonal.database.LotteryTicketRepository;
41-
import com.iluwatar.hexagonal.database.LotteryTicketRepositoryMock;
41+
import com.iluwatar.hexagonal.database.LotteryTicketInMemoryRepository;
4242
import com.iluwatar.hexagonal.domain.LotteryNumbers;
4343
import com.iluwatar.hexagonal.domain.LotteryTicket;
4444
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult;
@@ -57,7 +57,7 @@ public class LotteryTest {
5757

5858
private final LotteryAdministration admin = new LotteryAdministrationImpl();
5959
private final LotteryService service = new LotteryServiceImpl();
60-
private final LotteryTicketRepository repository = new LotteryTicketRepositoryMock();
60+
private final LotteryTicketRepository repository = new LotteryTicketInMemoryRepository();
6161
private final WireTransfers wireTransfers = new WireTransfersImpl();
6262

6363
@Before

0 commit comments

Comments
 (0)