mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-21 08:26:16 +00:00
docs: update gateway
This commit is contained in:
@@ -26,7 +26,6 @@ package com.iluwatar.gateway;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* ExternalServiceA is one of external services.
|
||||
@@ -40,4 +39,3 @@ class ExternalServiceA implements Gateway {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class ExternalServiceC implements Gateway {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
public void error() throws Exception {
|
||||
public void error() {
|
||||
// Simulate an exception
|
||||
throw new RuntimeException("Service C encountered an error");
|
||||
}
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
package com.iluwatar.gateway;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ServiceFactoryTest {
|
||||
private GatewayFactory gatewayFactory;
|
||||
@@ -65,7 +65,7 @@ public class ServiceFactoryTest {
|
||||
@Test
|
||||
public void testGatewayFactoryRegistrationWithNonExistingKey() {
|
||||
Gateway nonExistingService = gatewayFactory.getGateway("NonExistingService");
|
||||
assertEquals(null, nonExistingService);
|
||||
assertNull(nonExistingService);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,6 +88,6 @@ public class ServiceFactoryTest {
|
||||
}
|
||||
|
||||
latch.await();
|
||||
assertTrue("This should not fail", !failed.get());
|
||||
assertFalse("This should not fail", failed.get());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user