Skip to content

Commit

Permalink
refactor: remove code smell java:S5786 (iluwatar#2159)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvolkmann authored Oct 30, 2022
1 parent 5afc32c commit 4cd8149
Show file tree
Hide file tree
Showing 155 changed files with 273 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testVisitForHayes() {

@BeforeEach
@AfterEach
public void clearLoggers() {
void clearLoggers() {
TestLoggerFactory.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ConfigureForUnixVisitorTest {

@BeforeEach
@AfterEach
public void clearLoggers() {
void clearLoggers() {
TestLoggerFactory.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AdapterPatternTest {
* This method runs before the test execution and sets the bean objects in the beans Map.
*/
@BeforeEach
public void setup() {
void setup() {
beans = new HashMap<>();

var fishingBoatAdapter = spy(new FishingBoatAdapter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AggregatorTest {
private ProductInventoryClient inventoryClient;

@BeforeEach
public void setup() {
void setup() {
MockitoAnnotations.openMocks(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ApiGatewayTest {
private PriceClient priceClient;

@BeforeEach
public void setup() {
void setup() {
MockitoAnnotations.openMocks(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BusinessDelegateTest {
* execution of every test.
*/
@BeforeEach
public void setup() {
void setup() {
netflixService = spy(new NetflixService());
youTubeService = spy(new YouTubeService());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CachingTest {
* Setup of application test includes: initializing DB connection and cache size/capacity.
*/
@BeforeEach
public void setUp() {
void setUp() {
// VirtualDB (instead of MongoDB) was used in running the JUnit tests
// to avoid Maven compilation errors. Set flag to true to run the
// tests with MongoDB (provided that MongoDB is installed and socket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* <p>
* Could be done with mock objects as well where the call method call is verified.
*/
public class CallbackTest {
class CallbackTest {

private Integer callingCount = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* App Test showing usage of circuit breaker.
*/
public class AppTest {
class AppTest {

private static final Logger LOGGER = LoggerFactory.getLogger(AppTest.class);

Expand All @@ -60,7 +60,7 @@ public class AppTest {
* and retry time period of 2 seconds.
*/
@BeforeEach
public void setupCircuitBreakers() {
void setupCircuitBreakers() {
var delayedService = new DelayedRemoteService(System.nanoTime(), STARTUP_DELAY);
//Set the circuit Breaker parameters
delayedServiceCircuitBreaker = new DefaultCircuitBreaker(delayedService, 3000,
Expand All @@ -78,7 +78,7 @@ public void setupCircuitBreakers() {
}

@Test
public void testFailure_OpenStateTransition() {
void testFailure_OpenStateTransition() {
//Calling delayed service, which will be unhealthy till 4 seconds
assertEquals("Delayed service is down", monitoringService.delayedServiceResponse());
//As failure threshold is "1", the circuit breaker is changed to OPEN
Expand All @@ -93,7 +93,7 @@ public void testFailure_OpenStateTransition() {
}

@Test
public void testFailure_HalfOpenStateTransition() {
void testFailure_HalfOpenStateTransition() {
//Calling delayed service, which will be unhealthy till 4 seconds
assertEquals("Delayed service is down", monitoringService.delayedServiceResponse());
//As failure threshold is "1", the circuit breaker is changed to OPEN
Expand All @@ -112,7 +112,7 @@ public void testFailure_HalfOpenStateTransition() {
}

@Test
public void testRecovery_ClosedStateTransition() {
void testRecovery_ClosedStateTransition() {
//Calling delayed service, which will be unhealthy till 4 seconds
assertEquals("Delayed service is down", monitoringService.delayedServiceResponse());
//As failure threshold is "1", the circuit breaker is changed to OPEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Circuit Breaker test
*/
public class DefaultCircuitBreakerTest {
class DefaultCircuitBreakerTest {

//long timeout, int failureThreshold, long retryTimePeriod
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void testDefaultConstructor() throws RemoteServiceException {
* @throws RemoteServiceException
*/
@Test
public void testParameterizedConstructor() throws RemoteServiceException {
void testParameterizedConstructor() throws RemoteServiceException {
var obj = new DelayedRemoteService(System.nanoTime()-2000*1000*1000,1);
assertEquals("Delayed service is working",obj.call());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* Unit test for Function class.
*/
@ExtendWith(MockitoExtension.class)
public class UsageCostProcessorFunctionTest {
class UsageCostProcessorFunctionTest {

@Mock
MessageHandlerUtility<UsageDetail> mockMessageHandlerUtilityForUsageADetail;
Expand All @@ -74,7 +74,7 @@ public class UsageCostProcessorFunctionTest {
UsageCostProcessorFunction usageCostProcessorFunction;

@BeforeEach
public void setUp() {
void setUp() {
var messageBodyUsageDetail = new MessageBody<UsageDetail>();
var usageDetailsList = new ArrayList<UsageDetail>();

Expand Down Expand Up @@ -122,7 +122,7 @@ public void setUp() {
* Unit test for HttpTriggerJava method.
*/
@Test
public void shouldTriggerHttpAzureFunctionJavaWithSubscriptionValidationEventType() throws Exception {
void shouldTriggerHttpAzureFunctionJavaWithSubscriptionValidationEventType() throws Exception {

// Setup
@SuppressWarnings("unchecked")
Expand All @@ -148,7 +148,7 @@ public HttpResponseMessage.Builder answer(InvocationOnMock invocation) {
}

@Test
public void shouldTriggerHttpAzureFunctionJavaWithUsageDetailEventType() throws Exception {
void shouldTriggerHttpAzureFunctionJavaWithUsageDetailEventType() throws Exception {
// Setup
@SuppressWarnings("unchecked")
final HttpRequestMessage<Optional<String>> req = mock(HttpRequestMessage.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Unit test for Function class.
*/
@ExtendWith(MockitoExtension.class)
public class UsageDetailPublisherFunctionTest {
class UsageDetailPublisherFunctionTest {
@Mock
MessageHandlerUtility<UsageDetail> mockMessageHandlerUtility;
@Mock
Expand All @@ -65,7 +65,7 @@ public class UsageDetailPublisherFunctionTest {
* Unit test for HttpTriggerJava method.
*/
@Test
public void shouldTriggerHttpAzureFunctionJavaWithSubscriptionValidationEventType() throws Exception {
void shouldTriggerHttpAzureFunctionJavaWithSubscriptionValidationEventType() throws Exception {

// Setup
@SuppressWarnings("unchecked")
Expand All @@ -91,7 +91,7 @@ public HttpResponseMessage.Builder answer(InvocationOnMock invocation) {
}

@Test
public void shouldTriggerHttpAzureFunctionJavaWithUsageDetailEventType() throws Exception {
void shouldTriggerHttpAzureFunctionJavaWithUsageDetailEventType() throws Exception {

// Setup
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class EventHandlerUtilityTest {
class EventHandlerUtilityTest {

@Mock
EventGridPublisherClient<BinaryData> mockCustomEventClient;
Expand All @@ -49,7 +49,7 @@ public class EventHandlerUtilityTest {
EventHandlerUtility<Message<UsageDetail>> eventHandlerUtility;

@BeforeEach
public void setUp() {
void setUp() {

System.setProperty("EventGridURL", "https://www.dummyEndpoint.com/api/events");
System.setProperty("EventGridKey", "EventGridURL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
public class MessageHandlerUtilityTest {
class MessageHandlerUtilityTest {
@Mock
private BlobClient mockBlobClient;

Expand All @@ -63,7 +63,7 @@ public class MessageHandlerUtilityTest {
private MessageReference messageReference;

@BeforeEach
public void setUp() {
void setUp() {
System.setProperty("BlobStorageConnectionString", "https://www.dummyEndpoint.com/api/blobs");

var messageBody = new MessageBody<UsageDetail>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
and https://stackoverflow.com/questions/50211433/servlets-unit-testing
*/

public class AppServletTest extends Mockito{
class AppServletTest extends Mockito{
private String msgPartOne = "<h1>This Server Doesn't Support";
private String msgPartTwo = "Requests</h1>\n"
+ "<h2>Use a GET request with boolean values for the following parameters<h2>\n"
+ "<h3>'name'</h3>\n<h3>'bus'</h3>\n<h3>'sports'</h3>\n<h3>'sci'</h3>\n<h3>'world'</h3>";
private String destination = "newsDisplay.jsp";

@Test
public void testDoGet() throws Exception {
void testDoGet() throws Exception {
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
HttpServletResponse mockResp = Mockito.mock(HttpServletResponse.class);
RequestDispatcher mockDispatcher = Mockito.mock(RequestDispatcher.class);
Expand All @@ -64,7 +64,7 @@ public void testDoGet() throws Exception {
}

@Test
public void testDoPost() throws Exception {
void testDoPost() throws Exception {
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
HttpServletResponse mockResp = Mockito.mock(HttpServletResponse.class);
StringWriter stringWriter = new StringWriter();
Expand All @@ -78,7 +78,7 @@ public void testDoPost() throws Exception {
}

@Test
public void testDoPut() throws Exception {
void testDoPut() throws Exception {
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
HttpServletResponse mockResp = Mockito.mock(HttpServletResponse.class);
StringWriter stringWriter = new StringWriter();
Expand All @@ -92,7 +92,7 @@ public void testDoPut() throws Exception {
}

@Test
public void testDoDelete() throws Exception {
void testDoDelete() throws Exception {
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
HttpServletResponse mockResp = Mockito.mock(HttpServletResponse.class);
StringWriter stringWriter = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

import static org.junit.Assert.*;

public class JavaBeansTest {
class JavaBeansTest {
@Test
public void testDefaultConstructor() {
void testDefaultConstructor() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertEquals("DEFAULT_NAME", newBean.getName());
assertTrue(newBean.isBusinessInterest());
Expand All @@ -43,47 +43,47 @@ public void testDefaultConstructor() {
}

@Test
public void testNameGetterSetter() {
void testNameGetterSetter() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertEquals("DEFAULT_NAME", newBean.getName());
newBean.setName("TEST_NAME_ONE");
assertEquals("TEST_NAME_ONE", newBean.getName());
}

@Test
public void testBusinessSetterGetter() {
void testBusinessSetterGetter() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertTrue(newBean.isBusinessInterest());
newBean.setBusinessInterest(false);
assertFalse(newBean.isBusinessInterest());
}

@Test
public void testScienceSetterGetter() {
void testScienceSetterGetter() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertTrue(newBean.isScienceNewsInterest());
newBean.setScienceNewsInterest(false);
assertFalse(newBean.isScienceNewsInterest());
}

@Test
public void testSportsSetterGetter() {
void testSportsSetterGetter() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertTrue(newBean.isSportsInterest());
newBean.setSportsInterest(false);
assertFalse(newBean.isSportsInterest());
}

@Test
public void testWorldSetterGetter() {
void testWorldSetterGetter() {
ClientPropertiesBean newBean = new ClientPropertiesBean();
assertTrue(newBean.isWorldNewsInterest());
newBean.setWorldNewsInterest(false);
assertFalse(newBean.isWorldNewsInterest());
}

@Test
public void testRequestConstructor(){
void testRequestConstructor(){
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
ClientPropertiesBean newBean = new ClientPropertiesBean((mockReq));
assertEquals("DEFAULT_NAME", newBean.getName());
Expand Down
6 changes: 3 additions & 3 deletions dao/src/test/java/com/iluwatar/dao/DbCustomerDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ void createSchema() throws SQLException {
* Represents the scenario where DB connectivity is present.
*/
@Nested
public class ConnectionSuccess {
class ConnectionSuccess {

/**
* Setup for connection success scenario.
*
* @throws Exception if any error occurs.
*/
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
var dataSource = new JdbcDataSource();
dataSource.setURL(DB_URL);
dao = new DbCustomerDao(dataSource);
Expand Down Expand Up @@ -191,7 +191,7 @@ class ConnectivityIssue {
* @throws SQLException if any error occurs.
*/
@BeforeEach
public void setUp() throws SQLException {
void setUp() throws SQLException {
dao = new DbCustomerDao(mockedDatasource());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @author Jeroen Meulemeester
*/
public class ContentTest {
class ContentTest {

@Test
void testToString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @author Jeroen Meulemeester
*/
public class MenuItemTest {
class MenuItemTest {

@Test
void testToString() {
Expand Down
Loading

0 comments on commit 4cd8149

Please sign in to comment.