Skip to content

Commit 649971d

Browse files
committed
upgrade anti-corruption-layer deps
1 parent 5d1c1c0 commit 649971d

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

ambassador/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
<modelVersion>4.0.0</modelVersion>
3535
<artifactId>ambassador</artifactId>
3636
<dependencies>
37+
<dependency>
38+
<groupId>org.slf4j</groupId>
39+
<artifactId>slf4j-api</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>ch.qos.logback</groupId>
43+
<artifactId>logback-classic</artifactId>
44+
</dependency>
3745
<dependency>
3846
<groupId>org.junit.jupiter</groupId>
3947
<artifactId>junit-jupiter-engine</artifactId>

anti-corruption-layer/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>
48-
<groupId>junit</groupId>
49-
<artifactId>junit</artifactId>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-engine</artifactId>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>

anti-corruption-layer/src/test/java/com/iluwatar/corruption/system/AntiCorruptionLayerTest.java

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@
3030
import com.iluwatar.corruption.system.modern.ModernOrder;
3131
import com.iluwatar.corruption.system.modern.ModernShop;
3232
import com.iluwatar.corruption.system.modern.Shipment;
33-
import org.junit.Test;
34-
import org.junit.runner.RunWith;
33+
import org.junit.jupiter.api.Test;
3534
import org.springframework.beans.factory.annotation.Autowired;
3635
import org.springframework.boot.test.context.SpringBootTest;
37-
import org.springframework.test.context.junit4.SpringRunner;
3836

3937
import java.util.Optional;
4038

4139
import static org.junit.jupiter.api.Assertions.*;
4240

43-
@RunWith(SpringRunner.class)
41+
import org.junit.jupiter.api.extension.ExtendWith;
42+
import org.springframework.test.context.junit.jupiter.SpringExtension;
43+
44+
@ExtendWith(SpringExtension.class)
4445
@SpringBootTest
4546
public class AntiCorruptionLayerTest {
4647

@@ -50,19 +51,13 @@ public class AntiCorruptionLayerTest {
5051
@Autowired
5152
private ModernShop modernShop;
5253

53-
5454
/**
5555
* Test the anti-corruption layer.
5656
* Main intention is to demonstrate how the anti-corruption layer works.
57-
* <p>
5857
* The 2 shops (modern and legacy) should operate independently and in the same time synchronize the data.
59-
* To avoid corrupting the domain models of the 2 shops, we use an anti-corruption layer
60-
* that transforms one model to another under the hood.
61-
*
6258
*/
6359
@Test
6460
public void antiCorruptionLayerTest() throws ShopException {
65-
6661
// a new order comes to the legacy shop.
6762
LegacyOrder legacyOrder = new LegacyOrder("1", "addr1", "item1", 1, 1);
6863
// place the order in the legacy shop.
@@ -71,41 +66,32 @@ public void antiCorruptionLayerTest() throws ShopException {
7166
Optional<LegacyOrder> legacyOrderWithIdOne = legacyShop.findOrder("1");
7267
assertEquals(Optional.of(legacyOrder), legacyOrderWithIdOne);
7368

74-
// a new order (or maybe just the same order) appears in the modern shop.
69+
// a new order (or maybe just the same order) appears in the modern shop
7570
ModernOrder modernOrder = new ModernOrder("1", new Customer("addr1"), new Shipment("item1", 1, 1), "");
76-
7771
// the system places it, but it checks if there is an order with the same id in the legacy shop.
7872
modernShop.placeOrder(modernOrder);
7973

8074
Optional<ModernOrder> modernOrderWithIdOne = modernShop.findOrder("1");
8175
// there is no new order placed since there is already an order with the same id in the legacy shop.
8276
assertTrue(modernOrderWithIdOne.isEmpty());
83-
8477
}
78+
8579
/**
86-
* Test the anti-corruption layer.
87-
* Main intention is to demonstrate how the anti-corruption layer works.
88-
* <p>
89-
* This test tests the anti-corruption layer from the rule the orders should be the same in the both systems.
90-
*
80+
* Test the anti-corruption layer when a conflict occurs between systems.
81+
* This test ensures that an exception is thrown when conflicting orders are placed.
9182
*/
92-
@Test(expected = ShopException.class)
83+
@Test
9384
public void antiCorruptionLayerWithExTest() throws ShopException {
94-
9585
// a new order comes to the legacy shop.
9686
LegacyOrder legacyOrder = new LegacyOrder("1", "addr1", "item1", 1, 1);
9787
// place the order in the legacy shop.
9888
legacyShop.placeOrder(legacyOrder);
9989
// the order is placed as usual since there is no other orders with the id in the both systems.
10090
Optional<LegacyOrder> legacyOrderWithIdOne = legacyShop.findOrder("1");
10191
assertEquals(Optional.of(legacyOrder), legacyOrderWithIdOne);
102-
10392
// a new order but with the same id and different data appears in the modern shop
10493
ModernOrder modernOrder = new ModernOrder("1", new Customer("addr1"), new Shipment("item1", 10, 1), "");
105-
10694
// the system rejects the order since there are 2 orders with contradiction there.
107-
modernShop.placeOrder(modernOrder);
108-
109-
95+
assertThrows(ShopException.class, () -> modernShop.placeOrder(modernOrder));
11096
}
111-
}
97+
}

pom.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<properties>
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939
<sonar-maven-plugin.version>5.0.0.4389</sonar-maven-plugin.version>
40-
<!-- <spring-boot.version>2.7.5</spring-boot.version>-->
40+
<spring-boot.version>3.4.4</spring-boot.version>
4141
<jacoco.version>0.8.12</jacoco.version>
4242
<commons-dbcp.version>1.4</commons-dbcp.version>
4343
<htmlunit.version>4.7.0</htmlunit.version>
@@ -67,8 +67,8 @@
6767
<module>active-object</module>
6868
<module>acyclic-visitor</module>
6969
<module>adapter</module>
70-
<!-- <module>ambassador</module>-->
71-
<!-- <module>anti-corruption-layer</module>-->
70+
<module>ambassador</module>
71+
<module>anti-corruption-layer</module>
7272
<!-- <module>arrange-act-assert</module>-->
7373
<!-- <module>async-method-invocation</module>-->
7474
<!-- <module>balking</module>-->
@@ -245,6 +245,18 @@
245245
<!-- <type>pom</type>-->
246246
<!-- <scope>import</scope>-->
247247
<!-- </dependency>-->
248+
249+
<dependency>
250+
<groupId>org.springframework.boot</groupId>
251+
<artifactId>spring-boot-starter</artifactId>
252+
<version>${spring-boot.version}</version>
253+
</dependency>
254+
<dependency>
255+
<groupId>org.springframework.boot</groupId>
256+
<artifactId>spring-boot-starter-test</artifactId>
257+
<scope>test</scope>
258+
<version>${spring-boot.version}</version>
259+
</dependency>
248260
<dependency>
249261
<groupId>commons-dbcp</groupId>
250262
<artifactId>commons-dbcp</artifactId>

0 commit comments

Comments
 (0)