mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 10:59:17 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
+6
-10
@@ -24,23 +24,19 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Tests that EventAsynchronous example runs without errors.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests that EventAsynchronous example runs without errors. */
|
||||
class AppTest {
|
||||
|
||||
/**
|
||||
* Issue: Add at least one assertion to this test case.
|
||||
* Solution: Inserted assertion to check whether the execution of the main method in {@link App#main(String[])}
|
||||
* throws an exception.
|
||||
* Issue: Add at least one assertion to this test case. Solution: Inserted assertion to check
|
||||
* whether the execution of the main method in {@link App#main(String[])} throws an exception.
|
||||
*/
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
+29
-34
@@ -31,13 +31,11 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.time.Duration;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
/** Application test */
|
||||
class EventAsynchronousTest {
|
||||
|
||||
@Test
|
||||
@@ -46,7 +44,7 @@ class EventAsynchronousTest {
|
||||
var eventManager = new EventManager();
|
||||
var aEventId = eventManager.createAsync(Duration.ofSeconds(60));
|
||||
|
||||
assertDoesNotThrow(() ->eventManager.start(aEventId));
|
||||
assertDoesNotThrow(() -> eventManager.start(aEventId));
|
||||
|
||||
assertEquals(1, eventManager.getEventPool().size());
|
||||
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
|
||||
@@ -54,7 +52,6 @@ class EventAsynchronousTest {
|
||||
|
||||
assertDoesNotThrow(() -> eventManager.cancel(aEventId));
|
||||
assertTrue(eventManager.getEventPool().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,7 +67,6 @@ class EventAsynchronousTest {
|
||||
|
||||
assertDoesNotThrow(() -> eventManager.cancel(sEventId));
|
||||
assertTrue(eventManager.getEventPool().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,21 +82,21 @@ class EventAsynchronousTest {
|
||||
eventManager.start(sEventId);
|
||||
|
||||
await().until(() -> eventManager.getEventPool().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testUnsuccessfulSynchronousEvent() {
|
||||
assertThrows(InvalidOperationException.class, () -> {
|
||||
var eventManager = new EventManager();
|
||||
assertThrows(
|
||||
InvalidOperationException.class,
|
||||
() -> {
|
||||
var eventManager = new EventManager();
|
||||
|
||||
var sEventId = assertDoesNotThrow(() -> eventManager.create(Duration.ofSeconds(60)));
|
||||
eventManager.start(sEventId);
|
||||
sEventId = eventManager.create(Duration.ofSeconds(60));
|
||||
eventManager.start(sEventId);
|
||||
|
||||
});
|
||||
var sEventId = assertDoesNotThrow(() -> eventManager.create(Duration.ofSeconds(60)));
|
||||
eventManager.start(sEventId);
|
||||
sEventId = eventManager.create(Duration.ofSeconds(60));
|
||||
eventManager.start(sEventId);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,28 +115,27 @@ class EventAsynchronousTest {
|
||||
eventManager.start(aEventId3);
|
||||
|
||||
await().until(() -> eventManager.getEventPool().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLongRunningEventException(){
|
||||
assertThrows(LongRunningEventException.class, () -> {
|
||||
var eventManager = new EventManager();
|
||||
eventManager.createAsync(Duration.ofMinutes(31));
|
||||
});
|
||||
void testLongRunningEventException() {
|
||||
assertThrows(
|
||||
LongRunningEventException.class,
|
||||
() -> {
|
||||
var eventManager = new EventManager();
|
||||
eventManager.createAsync(Duration.ofMinutes(31));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testMaxNumOfEventsAllowedException(){
|
||||
assertThrows(MaxNumOfEventsAllowedException.class, () -> {
|
||||
final var eventManager = new EventManager();
|
||||
for(int i=0;i<1100;i++){
|
||||
eventManager.createAsync(Duration.ofSeconds(i));
|
||||
}
|
||||
});
|
||||
void testMaxNumOfEventsAllowedException() {
|
||||
assertThrows(
|
||||
MaxNumOfEventsAllowedException.class,
|
||||
() -> {
|
||||
final var eventManager = new EventManager();
|
||||
for (int i = 0; i < 1100; i++) {
|
||||
eventManager.createAsync(Duration.ofSeconds(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user