Removed visibility modifier code smells
This commit is contained in:
@@ -22,7 +22,7 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import de.rwu.easydrop.api.client.AmazonProductDataSource;
|
import de.rwu.easydrop.api.client.AmazonProductDataSource;
|
||||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||||
|
|
||||||
public class AmazonProductDataSourceTest {
|
class AmazonProductDataSourceTest {
|
||||||
|
|
||||||
private AmazonProductDataSource demoDataSource;
|
private AmazonProductDataSource demoDataSource;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
private static String demoProductId = "whateverId";
|
private static String demoProductId = "whateverId";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
void setup() {
|
||||||
demoDataSource = new AmazonProductDataSource(
|
demoDataSource = new AmazonProductDataSource(
|
||||||
demoApiUrl,
|
demoApiUrl,
|
||||||
demoApiKey);
|
demoApiKey);
|
||||||
@@ -40,7 +40,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructor() {
|
void testConstructor() {
|
||||||
// Assert
|
// Assert
|
||||||
try {
|
try {
|
||||||
Field baseUrlField = AmazonProductDataSource.class.getDeclaredField("baseUrl");
|
Field baseUrlField = AmazonProductDataSource.class.getDeclaredField("baseUrl");
|
||||||
@@ -58,7 +58,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateApiUrl() throws MalformedURLException {
|
void testCreateApiUrl() throws MalformedURLException {
|
||||||
// Test case 1
|
// Test case 1
|
||||||
String productId1 = "12345";
|
String productId1 = "12345";
|
||||||
URL expectedUrl1 = new URL(
|
URL expectedUrl1 = new URL(
|
||||||
@@ -76,7 +76,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildProductDTO_completeData() {
|
void testBuildProductDTO_completeData() {
|
||||||
// Set up the test environment
|
// Set up the test environment
|
||||||
String json = "{\"featuredOffer\": {\"availability\": \"available\"," +
|
String json = "{\"featuredOffer\": {\"availability\": \"available\"," +
|
||||||
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
||||||
@@ -96,7 +96,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildProductDTO_incompleteData() {
|
void testBuildProductDTO_incompleteData() {
|
||||||
// Set up the test environment
|
// Set up the test environment
|
||||||
String json = "{\"otherOffer\": {\"availability\": \"available\"," +
|
String json = "{\"otherOffer\": {\"availability\": \"available\"," +
|
||||||
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
||||||
@@ -116,7 +116,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProductDTOById_successfulRequest() throws IOException {
|
void testGetProductDTOById_successfulRequest() throws IOException {
|
||||||
// Set up the test environment
|
// Set up the test environment
|
||||||
String mockResponse = "{\"featuredOffer\": {\"availability\": \"available\"," +
|
String mockResponse = "{\"featuredOffer\": {\"availability\": \"available\"," +
|
||||||
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
"\"price\": {\"value\": {\"amount\": 10.0}}," +
|
||||||
@@ -146,7 +146,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProductDTOById_failedRequest() throws IOException {
|
void testGetProductDTOById_failedRequest() throws IOException {
|
||||||
// Set up the test environment
|
// Set up the test environment
|
||||||
|
|
||||||
AmazonProductDataSource dataSource = mock(AmazonProductDataSource.class);
|
AmazonProductDataSource dataSource = mock(AmazonProductDataSource.class);
|
||||||
@@ -167,7 +167,7 @@ public class AmazonProductDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProductDTOById_ioException() throws IOException {
|
void testGetProductDTOById_ioException() throws IOException {
|
||||||
// Set up the test environment
|
// Set up the test environment
|
||||||
AmazonProductDataSource dataSource = mock(AmazonProductDataSource.class);
|
AmazonProductDataSource dataSource = mock(AmazonProductDataSource.class);
|
||||||
URL mockURL = mock(URL.class);
|
URL mockURL = mock(URL.class);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import javax.naming.ConfigurationException;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ConfigImplTest {
|
class ConfigImplTest {
|
||||||
private Config config;
|
private Config config;
|
||||||
private final static String TESTDATA_PATH = "testResources/testdata.properties";
|
private final static String TESTDATA_PATH = "testResources/testdata.properties";
|
||||||
private final static String TESTDATA_KEY = "API_KEY";
|
private final static String TESTDATA_KEY = "API_KEY";
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import java.lang.reflect.Modifier;
|
|||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class FormattingUtilTest {
|
class FormattingUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructorIsPrivate()
|
void testConstructorIsPrivate()
|
||||||
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
// Check for private constructor
|
// Check for private constructor
|
||||||
Constructor<FormattingUtil> constructor = FormattingUtil.class.getDeclaredConstructor();
|
Constructor<FormattingUtil> constructor = FormattingUtil.class.getDeclaredConstructor();
|
||||||
@@ -27,7 +27,7 @@ public class FormattingUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatEuro_positiveAmount() {
|
void testFormatEuro_positiveAmount() {
|
||||||
double amount = 1234.56;
|
double amount = 1234.56;
|
||||||
String expectedFormattedAmount = "1.234,56 €";
|
String expectedFormattedAmount = "1.234,56 €";
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class FormattingUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatEuro_zeroAmount() {
|
void testFormatEuro_zeroAmount() {
|
||||||
double amount = 0.0;
|
double amount = 0.0;
|
||||||
String expectedFormattedAmount = "0,00 €";
|
String expectedFormattedAmount = "0,00 €";
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public class FormattingUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatEuro_negativeAmount() {
|
void testFormatEuro_negativeAmount() {
|
||||||
double amount = -789.12;
|
double amount = -789.12;
|
||||||
String expectedFormattedAmount = "-789,12 €";
|
String expectedFormattedAmount = "-789,12 €";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user