docs: update gateway

This commit is contained in:
Ilkka Seppälä
2024-04-23 18:55:49 +03:00
parent b00d79a79e
commit 78e57a5490
4 changed files with 52 additions and 33 deletions
@@ -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());
}
}