Amazon and eBay Buy/Sell APIs
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doCallRealMethod;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
import de.rwu.easydrop.exception.DataWriterException;
|
||||
|
||||
class AbstractDataWriterTest {
|
||||
private static String demoProductId = "whateverId";
|
||||
|
||||
@Mock
|
||||
private HttpURLConnection mockConnection;
|
||||
@Mock
|
||||
private URL mockUrl;
|
||||
|
||||
private AbstractDataWriter writer;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
writer = new AbstractDataWriter() {
|
||||
@Override
|
||||
protected String getApiKey() {
|
||||
return "testApiKey";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDataTarget() {
|
||||
return "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URL createApiUrl(String productIdentifier) throws MalformedURLException {
|
||||
return mockUrl;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendPutRequest_wrongDataSource_throwsException() {
|
||||
ProductDTO dto = new ProductDTO(demoProductId, "Amazon");
|
||||
|
||||
DataWriterException e = assertThrows(DataWriterException.class, () -> {
|
||||
writer.sendPutRequest(dto, "testApiType");
|
||||
});
|
||||
|
||||
assertEquals("Product data source and target testApiType API are incompatible.", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendPutRequest_badResponseCode_throwsException() throws IOException {
|
||||
// Set up DTO
|
||||
ProductDTO dto = new ProductDTO(demoProductId, "Test");
|
||||
|
||||
// Set up Mocks
|
||||
AbstractDataWriter mockWriter = mock(AbstractDataWriter.class);
|
||||
doCallRealMethod().when(mockWriter).sendPutRequest(any(), anyString());
|
||||
when(mockUrl.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_BAD_REQUEST);
|
||||
|
||||
DataWriterException e = assertThrows(DataWriterException.class, () -> {
|
||||
writer.sendPutRequest(dto, "Sales");
|
||||
});
|
||||
|
||||
assertEquals("Test Sales API responded with error code 400", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendPutRequest_ioException_throwsException() throws IOException {
|
||||
// Set up DTO
|
||||
ProductDTO dto = new ProductDTO(demoProductId, "Test");
|
||||
|
||||
// Set up Mocks
|
||||
AbstractDataWriter mockWriter = mock(AbstractDataWriter.class);
|
||||
doCallRealMethod().when(mockWriter).sendPutRequest(any(), anyString());
|
||||
when(mockUrl.openConnection()).thenThrow(new IOException());
|
||||
|
||||
DataWriterException e = assertThrows(DataWriterException.class, () -> {
|
||||
writer.sendPutRequest(dto, "testApiType");
|
||||
});
|
||||
|
||||
assertEquals("Couldn't fulfill Test API request", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendPutRequest_successfulRequest() throws IOException {
|
||||
// Set up DTO
|
||||
ProductDTO dto = new ProductDTO(demoProductId, "test");
|
||||
|
||||
// Set up Mocks
|
||||
AbstractDataWriter mockWriter = mock(AbstractDataWriter.class);
|
||||
URL mockURL = mock(URL.class);
|
||||
when(mockWriter.createApiUrl(demoProductId)).thenReturn(mockURL);
|
||||
doCallRealMethod().when(mockWriter).sendPutRequest(any(), anyString());
|
||||
HttpURLConnection mockConnection = mock(HttpURLConnection.class);
|
||||
when(mockURL.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
|
||||
when(mockWriter.getDataTarget()).thenReturn("test");
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
mockWriter.sendPutRequest(dto, "Purchase");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doCallRealMethod;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
|
||||
class AbstractPurchaserTest {
|
||||
private AbstractPurchaser mockPurchaser = mock(AbstractPurchaser.class);
|
||||
|
||||
@Test
|
||||
void purchaseProduct_CorrectApiTypeInException() throws IOException {
|
||||
// Set up DTO
|
||||
ProductDTO dto = new ProductDTO("12345", "test");
|
||||
|
||||
// Set up mocks
|
||||
URL mockURL = mock(URL.class);
|
||||
when(mockPurchaser.createApiUrl("12345")).thenReturn(mockURL);
|
||||
doCallRealMethod().when(mockPurchaser).purchaseProduct(any());
|
||||
HttpURLConnection mockConnection = mock(HttpURLConnection.class);
|
||||
when(mockURL.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
|
||||
when(mockPurchaser.getDataTarget()).thenReturn("test");
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
mockPurchaser.purchaseProduct(dto);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doCallRealMethod;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
|
||||
class AbstractSellerTest {
|
||||
private AbstractSeller mockSeller = mock(AbstractSeller.class);
|
||||
|
||||
@Test
|
||||
void purchaseProduct_CorrectApiTypeInException() throws IOException {
|
||||
// Set up DTO
|
||||
ProductDTO dto = new ProductDTO("12345", "test");
|
||||
|
||||
// Set up mocks
|
||||
URL mockURL = mock(URL.class);
|
||||
when(mockSeller.createApiUrl("12345")).thenReturn(mockURL);
|
||||
doCallRealMethod().when(mockSeller).sellProduct(any());
|
||||
HttpURLConnection mockConnection = mock(HttpURLConnection.class);
|
||||
when(mockURL.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
|
||||
when(mockSeller.getDataTarget()).thenReturn("test");
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
mockSeller.sellProduct(dto);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
import de.rwu.easydrop.exception.DataWriterException;
|
||||
|
||||
class AmazonPurchaserTest {
|
||||
private AmazonPurchaser demoPurchaser;
|
||||
|
||||
private static String demoApiKey = "my-api-key";
|
||||
private static String demoApiUrl = "https://www.example.com/api";
|
||||
private static String demoDataTarget = "Amazon";
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
demoPurchaser = new AmazonPurchaser(
|
||||
demoApiUrl,
|
||||
demoApiKey);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructor() {
|
||||
// Assert
|
||||
try {
|
||||
Field baseUrlField = AmazonPurchaser.class.getDeclaredField("baseUrl");
|
||||
baseUrlField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiUrl, baseUrlField.get(demoPurchaser));
|
||||
|
||||
Field apiKeyField = AmazonPurchaser.class.getDeclaredField("apiKey");
|
||||
apiKeyField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiKey, apiKeyField.get(demoPurchaser));
|
||||
} catch (NoSuchFieldException e) {
|
||||
Assertions.fail();
|
||||
} catch (IllegalAccessException e) {
|
||||
Assertions.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateApiUrl() throws MalformedURLException {
|
||||
// Test case 1
|
||||
String productId1 = "12345";
|
||||
URL expectedUrl1 = new URL(
|
||||
"https://www.example.com/api/products/2020-08-26/products/"
|
||||
+ productId1
|
||||
+ "/buy?productRegion=DE&locale=de_DE");
|
||||
URL createdUrl1 = demoPurchaser.createApiUrl(productId1);
|
||||
Assertions.assertEquals(expectedUrl1, createdUrl1);
|
||||
|
||||
// Test case 2
|
||||
String productId2 = "67890";
|
||||
URL expectedUrl2 = new URL(
|
||||
"https://www.example.com/api/products/2020-08-26/"
|
||||
+ "products/"
|
||||
+ productId2
|
||||
+ "/buy?productRegion=DE&locale=de_DE");
|
||||
URL createdUrl2 = demoPurchaser.createApiUrl(productId2);
|
||||
Assertions.assertEquals(expectedUrl2, createdUrl2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDataTarget_ReturnsExpectedDataOrigin() {
|
||||
String dataTarget = demoPurchaser.getDataTarget();
|
||||
assertEquals(demoDataTarget, dataTarget);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApiKey_ReturnsExpectedApiKey() {
|
||||
String apiKey = demoPurchaser.getApiKey();
|
||||
assertEquals(demoApiKey, apiKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
class AmazonSellerTest {
|
||||
private AmazonSeller demoSeller;
|
||||
|
||||
private static String demoApiKey = "my-api-key";
|
||||
private static String demoApiUrl = "https://www.example.com/api";
|
||||
private static String demoDataTarget = "Amazon";
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
demoSeller = new AmazonSeller(
|
||||
demoApiUrl,
|
||||
demoApiKey);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructor() {
|
||||
// Assert
|
||||
try {
|
||||
Field baseUrlField = AmazonSeller.class.getDeclaredField("baseUrl");
|
||||
baseUrlField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiUrl, baseUrlField.get(demoSeller));
|
||||
|
||||
Field apiKeyField = AmazonSeller.class.getDeclaredField("apiKey");
|
||||
apiKeyField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiKey, apiKeyField.get(demoSeller));
|
||||
} catch (NoSuchFieldException e) {
|
||||
Assertions.fail();
|
||||
} catch (IllegalAccessException e) {
|
||||
Assertions.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateApiUrl() throws MalformedURLException {
|
||||
// Test case 1
|
||||
String productId1 = "12345";
|
||||
URL expectedUrl1 = new URL(
|
||||
"https://www.example.com/api/products/2020-08-26/products/"
|
||||
+ productId1
|
||||
+ "/sell?productRegion=DE&locale=de_DE");
|
||||
URL createdUrl1 = demoSeller.createApiUrl(productId1);
|
||||
Assertions.assertEquals(expectedUrl1, createdUrl1);
|
||||
|
||||
// Test case 2
|
||||
String productId2 = "67890";
|
||||
URL expectedUrl2 = new URL(
|
||||
"https://www.example.com/api/products/2020-08-26/"
|
||||
+ "products/"
|
||||
+ productId2
|
||||
+ "/sell?productRegion=DE&locale=de_DE");
|
||||
URL createdUrl2 = demoSeller.createApiUrl(productId2);
|
||||
Assertions.assertEquals(expectedUrl2, createdUrl2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDataTarget_ReturnsExpectedDataOrigin() {
|
||||
String dataTarget = demoSeller.getDataTarget();
|
||||
assertEquals(demoDataTarget, dataTarget);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApiKey_ReturnsExpectedApiKey() {
|
||||
String apiKey = demoSeller.getApiKey();
|
||||
assertEquals(demoApiKey, apiKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
class EbayPurchaserTest {
|
||||
private EbayPurchaser demoPurchaser;
|
||||
|
||||
private static String demoApiKey = "my-api-key";
|
||||
private static String demoApiUrl = "https://www.example.com/api";
|
||||
private static String demoDataTarget = "eBay";
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
demoPurchaser = new EbayPurchaser(
|
||||
demoApiUrl,
|
||||
demoApiKey);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructor() {
|
||||
// Assert
|
||||
try {
|
||||
Field baseUrlField = EbayPurchaser.class.getDeclaredField("baseUrl");
|
||||
baseUrlField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiUrl, baseUrlField.get(demoPurchaser));
|
||||
|
||||
Field apiKeyField = EbayPurchaser.class.getDeclaredField("apiKey");
|
||||
apiKeyField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiKey, apiKeyField.get(demoPurchaser));
|
||||
} catch (NoSuchFieldException e) {
|
||||
Assertions.fail();
|
||||
} catch (IllegalAccessException e) {
|
||||
Assertions.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateApiUrl() throws MalformedURLException {
|
||||
// Test case 1
|
||||
String productId1 = "12345";
|
||||
URL expectedUrl1 = new URL(
|
||||
"https://www.example.com/api/buy/"
|
||||
+ productId1);
|
||||
URL createdUrl1 = demoPurchaser.createApiUrl(productId1);
|
||||
Assertions.assertEquals(expectedUrl1, createdUrl1);
|
||||
|
||||
// Test case 2
|
||||
String productId2 = "67890";
|
||||
URL expectedUrl2 = new URL(
|
||||
"https://www.example.com/api/buy/"
|
||||
+ productId2);
|
||||
URL createdUrl2 = demoPurchaser.createApiUrl(productId2);
|
||||
Assertions.assertEquals(expectedUrl2, createdUrl2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDataTarget_ReturnsExpectedDataOrigin() {
|
||||
String dataTarget = demoPurchaser.getDataTarget();
|
||||
assertEquals(demoDataTarget, dataTarget);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApiKey_ReturnsExpectedApiKey() {
|
||||
String apiKey = demoPurchaser.getApiKey();
|
||||
assertEquals(demoApiKey, apiKey);
|
||||
}
|
||||
}
|
||||
77
src/test/java/de/rwu/easydrop/api/client/EbaySellerTest.java
Normal file
77
src/test/java/de/rwu/easydrop/api/client/EbaySellerTest.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
class EbaySellerTest {
|
||||
private EbaySeller demoSeller;
|
||||
|
||||
private static String demoApiKey = "my-api-key";
|
||||
private static String demoApiUrl = "https://www.example.com/api";
|
||||
private static String demoDataTarget = "eBay";
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
demoSeller = new EbaySeller(
|
||||
demoApiUrl,
|
||||
demoApiKey);
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructor() {
|
||||
// Assert
|
||||
try {
|
||||
Field baseUrlField = EbaySeller.class.getDeclaredField("baseUrl");
|
||||
baseUrlField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiUrl, baseUrlField.get(demoSeller));
|
||||
|
||||
Field apiKeyField = EbaySeller.class.getDeclaredField("apiKey");
|
||||
apiKeyField.setAccessible(true);
|
||||
Assertions.assertEquals(demoApiKey, apiKeyField.get(demoSeller));
|
||||
} catch (NoSuchFieldException e) {
|
||||
Assertions.fail();
|
||||
} catch (IllegalAccessException e) {
|
||||
Assertions.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateApiUrl() throws MalformedURLException {
|
||||
// Test case 1
|
||||
String productId1 = "12345";
|
||||
URL expectedUrl1 = new URL(
|
||||
"https://www.example.com/api/sell/"
|
||||
+ productId1);
|
||||
URL createdUrl1 = demoSeller.createApiUrl(productId1);
|
||||
Assertions.assertEquals(expectedUrl1, createdUrl1);
|
||||
|
||||
// Test case 2
|
||||
String productId2 = "67890";
|
||||
URL expectedUrl2 = new URL(
|
||||
"https://www.example.com/api/sell/"
|
||||
+ productId2);
|
||||
URL createdUrl2 = demoSeller.createApiUrl(productId2);
|
||||
Assertions.assertEquals(expectedUrl2, createdUrl2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDataTarget_ReturnsExpectedDataOrigin() {
|
||||
String dataTarget = demoSeller.getDataTarget();
|
||||
assertEquals(demoDataTarget, dataTarget);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApiKey_ReturnsExpectedApiKey() {
|
||||
String apiKey = demoSeller.getApiKey();
|
||||
assertEquals(demoApiKey, apiKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package de.rwu.easydrop.exception;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DataWriterExceptionTest {
|
||||
|
||||
@Test
|
||||
void constructor_WithMessage_SetsMessage() {
|
||||
// Arrange
|
||||
String message = "Data source error";
|
||||
|
||||
// Act
|
||||
DataWriterException exception = new DataWriterException(message);
|
||||
|
||||
// Assert
|
||||
assertEquals(message, exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void constructor_WithMessageAndCause_SetsMessageAndCause() {
|
||||
// Arrange
|
||||
String message = "Data source error";
|
||||
Throwable cause = new IllegalArgumentException("Invalid argument");
|
||||
|
||||
// Act
|
||||
DataWriterException exception = new DataWriterException(message, cause);
|
||||
|
||||
// Assert
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void constructor_WithNullMessage_SetsNullMessage() {
|
||||
// Act
|
||||
DataWriterException exception = new DataWriterException(null);
|
||||
|
||||
// Assert
|
||||
assertEquals(null, exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void constructor_WithNullCause_SetsNullCause() {
|
||||
// Act
|
||||
DataWriterException exception = new DataWriterException("Data source error", null);
|
||||
|
||||
// Assert
|
||||
assertEquals(null, exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throw_DataWriterException() {
|
||||
// Act and Assert
|
||||
assertThrows(DataWriterException.class, () -> {
|
||||
throw new DataWriterException("Data source error");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user