mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 00:59:37 +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:
+14
-13
@@ -24,16 +24,14 @@
|
||||
*/
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* AbstractDocument test class
|
||||
*/
|
||||
/** AbstractDocument test class */
|
||||
class AbstractDocumentTest {
|
||||
|
||||
private static final String KEY = "key";
|
||||
@@ -82,13 +80,16 @@ class AbstractDocumentTest {
|
||||
|
||||
@Test
|
||||
void shouldHandleExceptionDuringConstruction() {
|
||||
Map<String, Object> invalidProperties = null; // Invalid properties, causing NullPointerException
|
||||
Map<String, Object> invalidProperties =
|
||||
null; // Invalid properties, causing NullPointerException
|
||||
|
||||
// Throw null pointer exception
|
||||
assertThrows(NullPointerException.class, () -> {
|
||||
// Attempt to construct a document with invalid properties
|
||||
new DocumentImplementation(invalidProperties);
|
||||
});
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> {
|
||||
// Attempt to construct a document with invalid properties
|
||||
new DocumentImplementation(invalidProperties);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,11 +98,11 @@ class AbstractDocumentTest {
|
||||
DocumentImplementation nestedDocument = new DocumentImplementation(new HashMap<>());
|
||||
nestedDocument.put("nestedKey", "nestedValue");
|
||||
|
||||
|
||||
document.put("nested", nestedDocument);
|
||||
|
||||
// Retrieving the nested document
|
||||
DocumentImplementation retrievedNestedDocument = (DocumentImplementation) document.get("nested");
|
||||
DocumentImplementation retrievedNestedDocument =
|
||||
(DocumentImplementation) document.get("nested");
|
||||
|
||||
assertNotNull(retrievedNestedDocument);
|
||||
assertEquals("nestedValue", retrievedNestedDocument.get("nestedKey"));
|
||||
|
||||
@@ -24,25 +24,21 @@
|
||||
*/
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Simple App test
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Simple App test */
|
||||
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}
|
||||
* throws an exception.
|
||||
* <p>Solution: Inserted assertion to check whether the execution of the main method in {@link
|
||||
* App} throws an exception.
|
||||
*/
|
||||
|
||||
@Test
|
||||
void shouldExecuteAppWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,18 +24,16 @@
|
||||
*/
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.Part;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for Part and Car
|
||||
*/
|
||||
/** Test for Part and Car */
|
||||
class DomainTest {
|
||||
|
||||
private static final String TEST_PART_TYPE = "test-part-type";
|
||||
@@ -47,11 +45,11 @@ class DomainTest {
|
||||
|
||||
@Test
|
||||
void shouldConstructPart() {
|
||||
var partProperties = Map.of(
|
||||
Property.TYPE.toString(), TEST_PART_TYPE,
|
||||
Property.MODEL.toString(), TEST_PART_MODEL,
|
||||
Property.PRICE.toString(), (Object) TEST_PART_PRICE
|
||||
);
|
||||
var partProperties =
|
||||
Map.of(
|
||||
Property.TYPE.toString(), TEST_PART_TYPE,
|
||||
Property.MODEL.toString(), TEST_PART_MODEL,
|
||||
Property.PRICE.toString(), (Object) TEST_PART_PRICE);
|
||||
var part = new Part(partProperties);
|
||||
assertEquals(TEST_PART_TYPE, part.getType().orElseThrow());
|
||||
assertEquals(TEST_PART_MODEL, part.getModel().orElseThrow());
|
||||
@@ -60,15 +58,14 @@ class DomainTest {
|
||||
|
||||
@Test
|
||||
void shouldConstructCar() {
|
||||
var carProperties = Map.of(
|
||||
Property.MODEL.toString(), TEST_CAR_MODEL,
|
||||
Property.PRICE.toString(), TEST_CAR_PRICE,
|
||||
Property.PARTS.toString(), List.of(Map.of(), Map.of())
|
||||
);
|
||||
var carProperties =
|
||||
Map.of(
|
||||
Property.MODEL.toString(), TEST_CAR_MODEL,
|
||||
Property.PRICE.toString(), TEST_CAR_PRICE,
|
||||
Property.PARTS.toString(), List.of(Map.of(), Map.of()));
|
||||
var car = new Car(carProperties);
|
||||
assertEquals(TEST_CAR_MODEL, car.getModel().orElseThrow());
|
||||
assertEquals(TEST_CAR_PRICE, car.getPrice().orElseThrow());
|
||||
assertEquals(2, car.getParts().count());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user