Skip to content
Permalink
Browse files
Remove unnecessary @SuppressWarnings("unchecked") and in-line single-use
local variable.
  • Loading branch information
garydgregory committed May 15, 2022
1 parent 8225fd0 commit f11ef63eecca75a0fa0c4ceb6dbb253725b99e48
Showing 15 changed files with 10 additions and 39 deletions.
@@ -155,7 +155,6 @@ public void testAsEventSourceSupported() {
*/
@Test
public void testAsEventSourceUnsupportedMock() {
@SuppressWarnings("unchecked")
final EventListener<ConfigurationEvent> cl = EasyMock.createMock(EventListener.class);
EasyMock.replay(cl);
final EventSource source = ConfigurationUtils.asEventSource(this, true);
@@ -152,9 +152,7 @@ public void initialize() {
* @return the event listener mock
*/
private static EventListener<ConfigurationEvent> createEventListener() {
@SuppressWarnings("unchecked")
final EventListener<ConfigurationEvent> listener = EasyMock.createMock(EventListener.class);
return listener;
return EasyMock.createMock(EventListener.class);
}

/**
@@ -49,7 +49,6 @@ public class TestBuilderConfigurationWrapperFactory {
* @return the mock builder
*/
private ConfigurationBuilder<BaseHierarchicalConfiguration> createBuilderMock(final BaseHierarchicalConfiguration conf) {
@SuppressWarnings("unchecked")
final ConfigurationBuilder<BaseHierarchicalConfiguration> builder = EasyMock.createMock(ConfigurationBuilder.class);
try {
EasyMock.expect(builder.getConfiguration()).andReturn(conf).anyTimes();
@@ -52,9 +52,7 @@ public class TestCombinedBuilderParametersImpl {
* @return the handler mock
*/
private static DefaultParametersHandler<BuilderParameters> createDefaultsHandlerMock() {
@SuppressWarnings("unchecked")
final DefaultParametersHandler<BuilderParameters> mock = EasyMock.createMock(DefaultParametersHandler.class);
return mock;
return EasyMock.createMock(DefaultParametersHandler.class);
}

/**
@@ -362,7 +362,6 @@ private CombinedConfiguration checkConfiguration() throws ConfigurationException
private void checkFileSystem(final File fsFile) throws ConfigurationException {
builder.configure(createParameters().setFile(fsFile));
builder.getConfiguration();
@SuppressWarnings("unchecked") // this is the minimum bound for type arguments
final FileBasedConfigurationBuilder<? extends Configuration> xmlBuilder = (FileBasedConfigurationBuilder<? extends Configuration>) builder
.getNamedBuilder("xml");
assertTrue("Wrong file system: " + xmlBuilder.getFileHandler().getFileSystem(),
@@ -632,9 +631,7 @@ public void testConfigurationBuilderProviderInheritCustomProviders() throws Conf
*/
@Test
public void testConfigurationBuilderProviderInheritEventListeners() throws ConfigurationException {
@SuppressWarnings("unchecked")
final EventListener<Event> l1 = EasyMock.createNiceMock(EventListener.class);
@SuppressWarnings("unchecked")
final EventListener<ConfigurationEvent> l2 = EasyMock.createNiceMock(EventListener.class);
EasyMock.replay(l1, l2);
final File testFile = ConfigurationAssert.getTestFile("testCCCombinedChildBuilder.xml");
@@ -98,7 +98,6 @@ private static MultiFileConfigurationBuilder<XMLConfiguration> createTestBuilder
@Test
public void testAddConfigurationListener() throws ConfigurationException {
final EventListener<ConfigurationEvent> l1 = new EventListenerTestImpl(null);
@SuppressWarnings("unchecked")
final EventListener<Event> l2 = EasyMock.createMock(EventListener.class);
EasyMock.replay(l2);
final MultiFileConfigurationBuilder<XMLConfiguration> builder = createTestBuilder(null);
@@ -92,9 +92,7 @@ private static void checkInstanceOf(final Object obj, final Class<?> cls) {
* @return the mock object
*/
private static DefaultParametersHandler<XMLBuilderParameters> createHandlerMock() {
@SuppressWarnings("unchecked")
final DefaultParametersHandler<XMLBuilderParameters> handler = EasyMock.createMock(DefaultParametersHandler.class);
return handler;
return EasyMock.createMock(DefaultParametersHandler.class);
}

@BeforeClass
@@ -253,7 +253,6 @@ public void testFireNullEvent() {
public void testGetEventListenerRegistrationsForSuperType() {
final ListenerTestImpl l1 = new ListenerTestImpl();
final ListenerTestImpl l2 = new ListenerTestImpl();
@SuppressWarnings("unchecked")
final EventListener<Event> l3 = EasyMock.createMock(EventListener.class);
list.addEventListener(typeSub1, l1);
list.addEventListener(Event.ANY, l3);
@@ -49,9 +49,7 @@ public class TestPeriodicReloadingTrigger {
* @return the mock
*/
private static ScheduledFuture<Void> createFutureMock() {
@SuppressWarnings("unchecked")
final ScheduledFuture<Void> mock = EasyMock.createMock(ScheduledFuture.class);
return mock;
return EasyMock.createMock(ScheduledFuture.class);
}

/** A mock for the executor service. */
@@ -39,9 +39,7 @@ public class TestReloadingController {
* @return the mock listener
*/
private static EventListener<ReloadingEvent> createListenerMock() {
@SuppressWarnings("unchecked")
final EventListener<ReloadingEvent> listener = EasyMock.createMock(EventListener.class);
return listener;
return EasyMock.createMock(EventListener.class);
}

/** A mock for the detector. */
@@ -190,9 +190,7 @@ private static ImmutableNode createPersonaeTree() {
* @return the resolver mock
*/
public static NodeKeyResolver<ImmutableNode> createResolverMock() {
@SuppressWarnings("unchecked")
final NodeKeyResolver<ImmutableNode> mock = EasyMock.createMock(NodeKeyResolver.class);
return mock;
return EasyMock.createMock(NodeKeyResolver.class);
}

/**
@@ -76,9 +76,7 @@ private static void checkPathToRoot(final InMemoryNodeModel model, ImmutableNode
* @return the mock for the resolver
*/
private static NodeKeyResolver<ImmutableNode> createResolver() {
@SuppressWarnings("unchecked")
final NodeKeyResolver<ImmutableNode> resolver = EasyMock.createMock(NodeKeyResolver.class);
return resolver;
return EasyMock.createMock(NodeKeyResolver.class);
}

/**
@@ -98,9 +98,7 @@ private static NodeHandler<ImmutableNode> createHandler() {
* @return the handler mock
*/
private static NodeHandler<ImmutableNode> handlerMock() {
@SuppressWarnings("unchecked")
final NodeHandler<ImmutableNode> handler = EasyMock.createMock(NodeHandler.class);
return handler;
return EasyMock.createMock(NodeHandler.class);
}

/**
@@ -119,9 +117,7 @@ private static String visitAfterName(final String name) {
* @return the visitor mock
*/
private static ConfigurationNodeVisitor<ImmutableNode> visitorMock() {
@SuppressWarnings("unchecked")
final ConfigurationNodeVisitor<ImmutableNode> visitor = EasyMock.createMock(ConfigurationNodeVisitor.class);
return visitor;
return EasyMock.createMock(ConfigurationNodeVisitor.class);
}

/**
@@ -44,9 +44,7 @@ public static void setUpBeforeClass() throws Exception {

@Before
public void setUp() throws Exception {
@SuppressWarnings("unchecked")
final NodeHandler<ImmutableNode> h = EasyMock.createMock(NodeHandler.class);
parentHandler = h;
parentHandler = EasyMock.createMock(NodeHandler.class);
handler = new TrackedNodeHandler(root, parentHandler);
}

@@ -44,7 +44,6 @@ public class TestTrackedNodeModel {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
selector = new NodeSelector("someKey");
@SuppressWarnings("unchecked")
final NodeKeyResolver<ImmutableNode> resolverMock = EasyMock.createMock(NodeKeyResolver.class);
EasyMock.replay(resolverMock);
resolver = resolverMock;
@@ -62,7 +61,6 @@ public static void setUpBeforeClass() throws Exception {
* @return the mock for the node handler
*/
private NodeHandler<ImmutableNode> expectGetNodeHandler() {
@SuppressWarnings("unchecked")
final NodeHandler<ImmutableNode> handler = EasyMock.createMock(NodeHandler.class);
EasyMock.expect(parentModel.getTrackedNodeHandler(selector)).andReturn(handler);
return handler;

0 comments on commit f11ef63

Please sign in to comment.