diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java index 02b04c0bf0..9023b8d157 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java @@ -16,16 +16,16 @@ */ package org.apache.nifi.registry.db; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @Transactional -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = DatabaseTestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) @TestExecutionListeners({DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class}) public abstract class DatabaseBaseTest { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseKeyService.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseKeyService.java index d0ab56ae30..d66f0944a2 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseKeyService.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseKeyService.java @@ -18,12 +18,12 @@ package org.apache.nifi.registry.db; import org.apache.nifi.registry.security.key.Key; import org.apache.nifi.registry.security.key.KeyService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; public class TestDatabaseKeyService extends DatabaseBaseTest { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseMetadataService.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseMetadataService.java index 2cf1823eab..8168a5a13e 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseMetadataService.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/TestDatabaseMetadataService.java @@ -36,7 +36,7 @@ import org.apache.nifi.extension.ExtensionFilterParams; import org.apache.nifi.extension.manifest.ExtensionType; import org.apache.nifi.extension.manifest.ProvidedServiceAPI; import org.apache.nifi.registry.service.MetadataService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; @@ -47,11 +47,11 @@ import java.util.List; import java.util.Set; import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestDatabaseMetadataService extends DatabaseBaseTest { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/migration/TestLegacyEntityMapper.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/migration/TestLegacyEntityMapper.java index 3de297f6c2..bb42bb3204 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/migration/TestLegacyEntityMapper.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/migration/TestLegacyEntityMapper.java @@ -19,12 +19,12 @@ package org.apache.nifi.registry.db.migration; import org.apache.nifi.registry.db.entity.BucketEntity; import org.apache.nifi.registry.db.entity.FlowEntity; import org.apache.nifi.registry.db.entity.FlowSnapshotEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Date; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class TestLegacyEntityMapper { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java index d51a15fd74..dc08928808 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java @@ -30,12 +30,12 @@ import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.hook.Event; import org.apache.nifi.registry.hook.EventFieldName; import org.apache.nifi.registry.hook.EventType; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.UUID; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestEventFactory { @@ -47,7 +47,7 @@ public class TestEventFactory { private User user; private UserGroup userGroup; - @Before + @BeforeEach public void setup() { bucket = new Bucket(); bucket.setName("Bucket1"); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java index 0270dd8ec6..cab38e97c5 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java @@ -22,29 +22,30 @@ import org.apache.nifi.registry.hook.EventHookException; import org.apache.nifi.registry.hook.EventHookProvider; import org.apache.nifi.registry.provider.ProviderConfigurationContext; import org.apache.nifi.registry.provider.ProviderCreationException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestEventService { private CapturingEventHook eventHook; private EventService eventService; - @Before + @BeforeEach public void setup() { eventHook = new CapturingEventHook(); eventService = new EventService(Collections.singletonList(eventHook)); eventService.postConstruct(); } - @After + @AfterEach public void teardown() throws Exception { eventService.destroy(); } @@ -63,13 +64,13 @@ public class TestEventService { Thread.sleep(1000); final List events = eventHook.getEvents(); - Assert.assertEquals(2, events.size()); + assertEquals(2, events.size()); final Event firstEvent = events.get(0); - Assert.assertEquals(bucketCreatedEvent.getEventType(), firstEvent.getEventType()); + assertEquals(bucketCreatedEvent.getEventType(), firstEvent.getEventType()); final Event secondEvent = events.get(1); - Assert.assertEquals(bucketDeletedEvent.getEventType(), secondEvent.getEventType()); + assertEquals(bucketDeletedEvent.getEventType(), secondEvent.getEventType()); } /** diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java index 8e9f73f7ca..65f4097cd3 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java @@ -20,18 +20,20 @@ import org.apache.nifi.registry.hook.Event; import org.apache.nifi.registry.hook.EventField; import org.apache.nifi.registry.hook.EventFieldName; import org.apache.nifi.registry.hook.EventType; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; public class TestStandardEvent { - @Test(expected = IllegalStateException.class) + @Test public void testInvalidEvent() { final Event event = new StandardEvent.Builder() .eventType(EventType.CREATE_BUCKET) .build(); - event.validate(); + assertThrows(IllegalStateException.class, () -> event.validate()); } @Test @@ -41,7 +43,7 @@ public class TestStandardEvent { .build(); final EventField field = event.getField(EventFieldName.BUCKET_ID); - Assert.assertNull(field); + assertNull(field); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java index 75e10c6669..24d40e265e 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java @@ -21,15 +21,16 @@ import org.apache.nifi.registry.extension.ExtensionClassLoader; import org.apache.nifi.registry.extension.ExtensionManager; import org.apache.nifi.registry.flow.FlowPersistenceProvider; import org.apache.nifi.registry.properties.NiFiRegistryProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import javax.sql.DataSource; import java.net.URL; import java.util.Properties; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.any; import static org.mockito.Mockito.when; @@ -67,7 +68,7 @@ public class TestStandardProviderFactory { assertEquals("extension bar", mockBundlePersistenceProvider.getProperties().get("Extension Property 2")); } - @Test(expected = ProviderFactoryException.class) + @Test public void testGetFlowProviderBeforeInitializingShouldThrowException() { final Properties properties = new Properties(); properties.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml"); @@ -80,10 +81,10 @@ public class TestStandardProviderFactory { final DataSource dataSource = Mockito.mock(DataSource.class); final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager, dataSource); - providerFactory.getFlowPersistenceProvider(); + assertThrows(ProviderFactoryException.class, () -> providerFactory.getFlowPersistenceProvider()); } - @Test(expected = ProviderFactoryException.class) + @Test public void testProvidersConfigDoesNotExist() { final Properties properties = new Properties(); properties.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-does-not-exist.xml"); @@ -96,10 +97,10 @@ public class TestStandardProviderFactory { final DataSource dataSource = Mockito.mock(DataSource.class); final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager, dataSource); - providerFactory.initialize(); + assertThrows(ProviderFactoryException.class, () -> providerFactory.initialize()); } - @Test(expected = ProviderFactoryException.class) + @Test public void testFlowProviderClassNotFound() { final Properties properties = new Properties(); properties.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-class-not-found.xml"); @@ -114,7 +115,7 @@ public class TestStandardProviderFactory { final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager, dataSource); providerFactory.initialize(); - providerFactory.getFlowPersistenceProvider(); + assertThrows(ProviderFactoryException.class, () -> providerFactory.getFlowPersistenceProvider()); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/extension/TestFileSystemBundlePersistenceProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/extension/TestFileSystemBundlePersistenceProvider.java index 75c3cacf7a..fe8dc0749f 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/extension/TestFileSystemBundlePersistenceProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/extension/TestFileSystemBundlePersistenceProvider.java @@ -24,9 +24,8 @@ import org.apache.nifi.registry.extension.BundlePersistenceProvider; import org.apache.nifi.registry.extension.BundleVersionCoordinate; import org.apache.nifi.registry.extension.BundleVersionType; import org.apache.nifi.registry.provider.ProviderConfigurationContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.io.ByteArrayInputStream; @@ -40,6 +39,11 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.when; public class TestFileSystemBundlePersistenceProvider { @@ -58,7 +62,7 @@ public class TestFileSystemBundlePersistenceProvider { private File bundleStorageDir; private BundlePersistenceProvider fileSystemBundleProvider; - @Before + @BeforeEach public void setup() throws IOException { bundleStorageDir = new File(EXTENSION_STORAGE_DIR); if (bundleStorageDir.exists()) { @@ -66,11 +70,11 @@ public class TestFileSystemBundlePersistenceProvider { bundleStorageDir.delete(); } - Assert.assertFalse(bundleStorageDir.exists()); + assertFalse(bundleStorageDir.exists()); fileSystemBundleProvider = new FileSystemBundlePersistenceProvider(); fileSystemBundleProvider.onConfigured(CONFIGURATION_CONTEXT); - Assert.assertTrue(bundleStorageDir.exists()); + assertTrue(bundleStorageDir.exists()); } @Test @@ -109,7 +113,7 @@ public class TestFileSystemBundlePersistenceProvider { try { final String newContent = "new content"; createBundleVersion(fileSystemBundleProvider, versionCoordinate, newContent); - Assert.fail("Should have thrown exception"); + fail("Should have thrown exception"); } catch (BundlePersistenceException e) { // expected } @@ -136,7 +140,7 @@ public class TestFileSystemBundlePersistenceProvider { try (final OutputStream out = new ByteArrayOutputStream()) { fileSystemBundleProvider.getBundleVersionContent(versionCoordinate, out); final String retrievedContent = new String(((ByteArrayOutputStream) out).toByteArray(), StandardCharsets.UTF_8); - Assert.assertEquals(newContent, retrievedContent); + assertEquals(newContent, retrievedContent); } } @@ -159,18 +163,18 @@ public class TestFileSystemBundlePersistenceProvider { fileSystemBundleProvider.getBundleVersionContent(versionCoordinate1, out); final String retrievedContent1 = new String(((ByteArrayOutputStream) out).toByteArray(), StandardCharsets.UTF_8); - Assert.assertEquals(content1, retrievedContent1); + assertEquals(content1, retrievedContent1); } try (final OutputStream out = new ByteArrayOutputStream()) { fileSystemBundleProvider.getBundleVersionContent(versionCoordinate2, out); final String retrievedContent2 = new String(((ByteArrayOutputStream) out).toByteArray(), StandardCharsets.UTF_8); - Assert.assertEquals(content2, retrievedContent2); + assertEquals(content2, retrievedContent2); } } - @Test(expected = BundlePersistenceException.class) + @Test public void testGetWhenDoesNotExist() throws IOException { final String bucketId = "b1"; final String groupId = "g1"; @@ -180,8 +184,7 @@ public class TestFileSystemBundlePersistenceProvider { try (final OutputStream out = new ByteArrayOutputStream()) { final BundleVersionCoordinate versionCoordinate = getVersionCoordinate(bucketId, groupId, artifactId, version, type); - fileSystemBundleProvider.getBundleVersionContent(versionCoordinate, out); - Assert.fail("Should have thrown exception"); + assertThrows(BundlePersistenceException.class, () -> fileSystemBundleProvider.getBundleVersionContent(versionCoordinate, out)); } } @@ -206,7 +209,7 @@ public class TestFileSystemBundlePersistenceProvider { // verify it was deleted final File bundleVersionDir = FileSystemBundlePersistenceProvider.getBundleVersionDirectory(bundleStorageDir, versionCoordinate); final File bundleFile = FileSystemBundlePersistenceProvider.getBundleFile(bundleVersionDir, versionCoordinate); - Assert.assertFalse(bundleFile.exists()); + assertFalse(bundleFile.exists()); } @Test @@ -222,7 +225,7 @@ public class TestFileSystemBundlePersistenceProvider { // verify the bundle version does not already exist final File bundleVersionDir = FileSystemBundlePersistenceProvider.getBundleVersionDirectory(bundleStorageDir, versionCoordinate); final File bundleFile = FileSystemBundlePersistenceProvider.getBundleFile(bundleVersionDir, versionCoordinate); - Assert.assertFalse(bundleFile.exists()); + assertFalse(bundleFile.exists()); // delete the bundle version fileSystemBundleProvider.deleteBundleVersion(versionCoordinate); @@ -249,10 +252,10 @@ public class TestFileSystemBundlePersistenceProvider { createBundleVersion(fileSystemBundleProvider, versionCoordinate2, content2); verifyBundleVersion(bundleStorageDir, versionCoordinate2, content2); - Assert.assertEquals(1, bundleStorageDir.listFiles().length); + assertEquals(1, bundleStorageDir.listFiles().length); final BundleCoordinate bundleCoordinate = getBundleCoordinate(bucketId, groupId, artifactId); fileSystemBundleProvider.deleteAllBundleVersions(bundleCoordinate); - Assert.assertEquals(0, bundleStorageDir.listFiles().length); + assertEquals(0, bundleStorageDir.listFiles().length); } @Test @@ -261,10 +264,10 @@ public class TestFileSystemBundlePersistenceProvider { final String groupId = "g1"; final String artifactId = "a1"; - Assert.assertEquals(0, bundleStorageDir.listFiles().length); + assertEquals(0, bundleStorageDir.listFiles().length); final BundleCoordinate bundleCoordinate = getBundleCoordinate(bucketId, groupId, artifactId); fileSystemBundleProvider.deleteAllBundleVersions(bundleCoordinate); - Assert.assertEquals(0, bundleStorageDir.listFiles().length); + assertEquals(0, bundleStorageDir.listFiles().length); } private void createBundleVersion(final BundlePersistenceProvider persistenceProvider, @@ -316,10 +319,10 @@ public class TestFileSystemBundlePersistenceProvider { final File bundleVersionDir = FileSystemBundlePersistenceProvider.getBundleVersionDirectory(storageDir, versionCoordinate); final File bundleFile = FileSystemBundlePersistenceProvider.getBundleFile(bundleVersionDir, versionCoordinate); - Assert.assertTrue(bundleFile.exists()); + assertTrue(bundleFile.exists()); try (InputStream in = new FileInputStream(bundleFile)) { - Assert.assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8)); + assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8)); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestDatabaseFlowPersistenceProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestDatabaseFlowPersistenceProvider.java index 5851b21805..eb74453f2a 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestDatabaseFlowPersistenceProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestDatabaseFlowPersistenceProvider.java @@ -19,17 +19,17 @@ package org.apache.nifi.registry.provider.flow; import org.apache.nifi.registry.db.DatabaseBaseTest; import org.apache.nifi.registry.flow.FlowPersistenceProvider; import org.apache.nifi.registry.flow.FlowSnapshotContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import javax.sql.DataSource; import java.nio.charset.StandardCharsets; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.when; public class TestDatabaseFlowPersistenceProvider extends DatabaseBaseTest { @@ -39,7 +39,7 @@ public class TestDatabaseFlowPersistenceProvider extends DatabaseBaseTest { private FlowPersistenceProvider persistenceProvider; - @Before + @BeforeEach public void setup() { persistenceProvider = new DatabaseFlowPersistenceProvider(); ((DatabaseFlowPersistenceProvider)persistenceProvider).setDataSource(dataSource); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java index 14a4861380..c8f7c06548 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java @@ -20,9 +20,8 @@ import org.apache.commons.io.IOUtils; import org.apache.nifi.registry.flow.FlowPersistenceProvider; import org.apache.nifi.registry.flow.FlowSnapshotContext; import org.apache.nifi.registry.provider.ProviderConfigurationContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.io.File; @@ -33,6 +32,12 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.when; public class TestFileSystemFlowPersistenceProvider { @@ -51,7 +56,7 @@ public class TestFileSystemFlowPersistenceProvider { private File flowStorageDir; private FileSystemFlowPersistenceProvider fileSystemFlowProvider; - @Before + @BeforeEach public void setup() throws IOException { flowStorageDir = new File(FLOW_STORAGE_DIR); if (flowStorageDir.exists()) { @@ -59,11 +64,11 @@ public class TestFileSystemFlowPersistenceProvider { flowStorageDir.delete(); } - Assert.assertFalse(flowStorageDir.exists()); + assertFalse(flowStorageDir.exists()); fileSystemFlowProvider = new FileSystemFlowPersistenceProvider(); fileSystemFlowProvider.onConfigured(CONFIGURATION_CONTEXT); - Assert.assertTrue(flowStorageDir.exists()); + assertTrue(flowStorageDir.exists()); } @Test @@ -95,7 +100,7 @@ public class TestFileSystemFlowPersistenceProvider { final byte[] content2 = "XXX".getBytes(StandardCharsets.UTF_8); try { fileSystemFlowProvider.saveFlowContent(context, content2); - Assert.fail("Should have thrown exception"); + fail("Should have thrown exception"); } catch (Exception e) { } @@ -103,7 +108,7 @@ public class TestFileSystemFlowPersistenceProvider { // verify the new content wasn't written final File flowSnapshotFile = new File(flowStorageDir, "bucket1/flow1/1/1" + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION); try (InputStream in = new FileInputStream(flowSnapshotFile)) { - Assert.assertEquals("flow1v1", IOUtils.toString(in, StandardCharsets.UTF_8)); + assertEquals("flow1v1", IOUtils.toString(in, StandardCharsets.UTF_8)); } } @@ -113,16 +118,16 @@ public class TestFileSystemFlowPersistenceProvider { createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 2, "flow1v2"); final byte[] flow1v1 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 1); - Assert.assertEquals("flow1v1", new String(flow1v1, StandardCharsets.UTF_8)); + assertEquals("flow1v1", new String(flow1v1, StandardCharsets.UTF_8)); final byte[] flow1v2 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 2); - Assert.assertEquals("flow1v2", new String(flow1v2, StandardCharsets.UTF_8)); + assertEquals("flow1v2", new String(flow1v2, StandardCharsets.UTF_8)); } @Test public void testGetWhenDoesNotExist() { final byte[] flow1v1 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 1); - Assert.assertNull(flow1v1); + assertNull(flow1v1); } @Test @@ -133,13 +138,13 @@ public class TestFileSystemFlowPersistenceProvider { createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1"); createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2"); - Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); - Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); + assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); + assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); fileSystemFlowProvider.deleteAllFlowContent(bucketId, flowId); - Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); - Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); + assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); + assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); // delete a flow that doesn't exist fileSystemFlowProvider.deleteAllFlowContent(bucketId, "some-other-flow"); @@ -156,18 +161,18 @@ public class TestFileSystemFlowPersistenceProvider { createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1"); createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2"); - Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); - Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); + assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); + assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 1); - Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); - Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); + assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); + assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 2); - Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); - Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); + assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1)); + assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2)); // delete a version that doesn't exist fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 3); @@ -195,10 +200,10 @@ public class TestFileSystemFlowPersistenceProvider { // verify the correct snapshot file was created final File flowSnapshotFile = new File(flowStorageDir, bucketId + "/" + flowId + "/" + version + "/" + version + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION); - Assert.assertTrue(flowSnapshotFile.exists()); + assertTrue(flowSnapshotFile.exists()); try (InputStream in = new FileInputStream(flowSnapshotFile)) { - Assert.assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8)); + assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8)); } } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFlowMetadataSynchronizer.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFlowMetadataSynchronizer.java index 6ee5e62e7a..c31b3ec172 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFlowMetadataSynchronizer.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFlowMetadataSynchronizer.java @@ -25,8 +25,8 @@ import org.apache.nifi.registry.metadata.BucketMetadata; import org.apache.nifi.registry.metadata.FlowMetadata; import org.apache.nifi.registry.metadata.FlowSnapshotMetadata; import org.apache.nifi.registry.service.MetadataService; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -46,7 +46,7 @@ public class TestFlowMetadataSynchronizer { private List metadata; private FlowMetadataSynchronizer synchronizer; - @Before + @BeforeEach public void setup() { metadataService = mock(MetadataService.class); metadataAwareflowPersistenceProvider = mock(MetadataAwareFlowPersistenceProvider.class); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java index bff2ef9153..9cc847ccc8 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java @@ -17,8 +17,9 @@ package org.apache.nifi.registry.provider.flow; import org.apache.nifi.registry.flow.FlowSnapshotContext; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestStandardFlowSnapshotContext { @@ -44,14 +45,14 @@ public class TestStandardFlowSnapshotContext { .snapshotTimestamp(timestamp) .build(); - Assert.assertEquals(bucketId, context.getBucketId()); - Assert.assertEquals(bucketName, context.getBucketName()); - Assert.assertEquals(flowId, context.getFlowId()); - Assert.assertEquals(flowName, context.getFlowName()); - Assert.assertEquals(version, context.getVersion()); - Assert.assertEquals(comments, context.getComments()); - Assert.assertEquals(author, context.getAuthor()); - Assert.assertEquals(timestamp, context.getSnapshotTimestamp()); + assertEquals(bucketId, context.getBucketId()); + assertEquals(bucketName, context.getBucketName()); + assertEquals(flowId, context.getFlowId()); + assertEquals(flowName, context.getFlowName()); + assertEquals(version, context.getVersion()); + assertEquals(comments, context.getComments()); + assertEquals(author, context.getAuthor()); + assertEquals(timestamp, context.getSnapshotTimestamp()); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java index a8b050a37e..c2809706aa 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java @@ -27,7 +27,7 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +40,9 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class TestGitFlowPersistenceProvider { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java index 0085bba95d..9ae2786c97 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java @@ -22,7 +22,7 @@ import org.apache.nifi.registry.properties.NiFiRegistryProperties; import org.apache.nifi.registry.provider.ProviderCreationException; import org.apache.nifi.registry.provider.ProviderFactory; import org.apache.nifi.registry.provider.StandardProviderFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import javax.sql.DataSource; @@ -30,12 +30,13 @@ import javax.sql.DataSource; import java.net.URL; import java.util.Properties; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; public class TestScriptEventHookProvider { - @Test(expected = ProviderCreationException.class) + @Test public void testBadScriptProvider() { final Properties properties = new Properties(); properties.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/hook/bad-script-provider.xml"); @@ -43,13 +44,16 @@ public class TestScriptEventHookProvider { final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class); when(extensionManager.getExtensionClassLoader(any(String.class))) - .thenReturn(new ExtensionClassLoader("/tmp", new URL[0],this.getClass().getClassLoader())); + .thenReturn(new ExtensionClassLoader("/tmp", new URL[0], this.getClass().getClassLoader())); final DataSource dataSource = Mockito.mock(DataSource.class); final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager, dataSource); - providerFactory.initialize(); - providerFactory.getEventHookProviders(); + assertThrows(ProviderCreationException.class, () -> { + providerFactory.initialize(); + providerFactory.getEventHookProviders(); + }); + } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/TestStandardAuthorizableLookup.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/TestStandardAuthorizableLookup.java index 2804ac730e..9f24f92e58 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/TestStandardAuthorizableLookup.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/TestStandardAuthorizableLookup.java @@ -23,15 +23,15 @@ import org.apache.nifi.registry.security.authorization.resource.ResourceFactory; import org.apache.nifi.registry.security.authorization.user.NiFiUser; import org.apache.nifi.registry.security.authorization.user.StandardNiFiUser; import org.apache.nifi.registry.service.RegistryService; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatcher; import java.util.UUID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; @@ -57,7 +57,7 @@ public class TestStandardAuthorizableLookup { private Bucket bucketPublic; private Bucket bucketNotPublic; - @Before + @BeforeEach public void setup() { authorizer = mock(Authorizer.class); registryService = mock(RegistryService.class); @@ -251,7 +251,7 @@ public class TestStandardAuthorizableLookup { final Authorizable bucketAuthorizable = authorizableLookup.getBucketAuthorizable(bucketPublic.getIdentifier()); try { bucketAuthorizable.authorize(authorizer, action, USER_NO_PROXY_CHAIN); - Assert.fail("Should have thrown exception"); + fail("Should have thrown exception"); } catch (AccessDeniedException e) { // Should never call authorizer twice for specific bucket and top-level /buckets verify(authorizer, times(2)).authorize(any(AuthorizationRequest.class)); @@ -272,7 +272,7 @@ public class TestStandardAuthorizableLookup { final Authorizable bucketAuthorizable = authorizableLookup.getBucketAuthorizable(bucketPublic.getIdentifier()); try { bucketAuthorizable.authorize(authorizer, action, USER_WITH_PROXY_CHAIN); - Assert.fail("Should have thrown exception"); + fail("Should have thrown exception"); } catch (UntrustedProxyException e) { // Should call authorizer once for /proxy and then throw exception verify(authorizer, times(1)).authorize(any(AuthorizationRequest.class)); @@ -307,7 +307,7 @@ public class TestStandardAuthorizableLookup { final Authorizable bucketAuthorizable = authorizableLookup.getBucketAuthorizable(bucketPublic.getIdentifier()); try { bucketAuthorizable.authorize(authorizer, action, user); - Assert.fail("Should have thrown exception"); + fail("Should have thrown exception"); } catch (AccessDeniedException e) { // Should call authorizer three times for /proxy, /bucket/{id}, and /buckets verify(authorizer, times(3)).authorize(any(AuthorizationRequest.class)); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseAccessPolicyProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseAccessPolicyProvider.java index 9c2cb60e00..16a720e8c3 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseAccessPolicyProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseAccessPolicyProvider.java @@ -34,8 +34,8 @@ import org.apache.nifi.registry.security.exception.SecurityProviderCreationExcep import org.apache.nifi.registry.security.identity.DefaultIdentityMapper; import org.apache.nifi.registry.security.identity.IdentityMapper; import org.apache.nifi.registry.util.StandardPropertyValue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -48,11 +48,12 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -85,7 +86,7 @@ public class TestDatabaseAccessPolicyProvider extends DatabaseBaseTest { // Class under test private ConfigurableAccessPolicyProvider policyProvider; - @Before + @BeforeEach public void setup() { properties = new NiFiRegistryProperties(); identityMapper = new DefaultIdentityMapper(properties); @@ -340,14 +341,14 @@ public class TestDatabaseAccessPolicyProvider extends DatabaseBaseTest { }); } - @Test(expected = SecurityProviderCreationException.class) + @Test public void testOnConfiguredWhenInitialAdminNotFound() { - configure("does-not-exist", null); + assertThrows(SecurityProviderCreationException.class, () -> configure("does-not-exist", null)); } - @Test(expected = SecurityProviderCreationException.class) + @Test public void testOnConfiguredWhenNiFiIdentityNotFound() { - configure(null, Collections.singleton("does-not-exist")); + assertThrows(SecurityProviderCreationException.class, () -> configure(null, Collections.singleton("does-not-exist"))); } // -- Test AccessPolicy methods diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseUserGroupProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseUserGroupProvider.java index dc14e66ee0..f38ad068bd 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseUserGroupProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/security/authorization/database/TestDatabaseUserGroupProvider.java @@ -27,8 +27,8 @@ import org.apache.nifi.registry.security.authorization.UserGroupProviderInitiali import org.apache.nifi.registry.security.authorization.util.UserGroupProviderUtils; import org.apache.nifi.registry.security.identity.DefaultIdentityMapper; import org.apache.nifi.registry.security.identity.IdentityMapper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -39,10 +39,10 @@ import java.util.Properties; import java.util.Set; import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -55,7 +55,7 @@ public class TestDatabaseUserGroupProvider extends DatabaseBaseTest { private ConfigurableUserGroupProvider userGroupProvider; - @Before + @BeforeEach public void setup() { properties = new NiFiRegistryProperties(); identityMapper = new DefaultIdentityMapper(properties); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestExtensionSerializer.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestExtensionSerializer.java index d274b7dd6a..7269788b85 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestExtensionSerializer.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestExtensionSerializer.java @@ -17,8 +17,8 @@ package org.apache.nifi.registry.serialization; import org.apache.nifi.extension.manifest.Extension; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -30,7 +30,7 @@ public class TestExtensionSerializer { private Serializer serializer; - @Before + @BeforeEach public void setup() { serializer = new ExtensionSerializer(); } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestFlowContentSerializer.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestFlowContentSerializer.java index 8bfcaabd94..1626e587b3 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestFlowContentSerializer.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestFlowContentSerializer.java @@ -20,8 +20,8 @@ import org.apache.nifi.flow.ExternalControllerServiceReference; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.flow.VersionedProcessor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -30,17 +30,17 @@ import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class TestFlowContentSerializer { private FlowContentSerializer serializer; - @Before + @BeforeEach public void setup() { serializer = new FlowContentSerializer(); } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/jaxb/TestJAXBVersionedProcessGroupSerializer.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/jaxb/TestJAXBVersionedProcessGroupSerializer.java index 3268b5f338..427ee1736f 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/jaxb/TestJAXBVersionedProcessGroupSerializer.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/jaxb/TestJAXBVersionedProcessGroupSerializer.java @@ -20,13 +20,14 @@ import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.flow.VersionedProcessor; import org.apache.nifi.registry.serialization.SerializationException; import org.apache.nifi.registry.serialization.VersionedSerializer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestJAXBVersionedProcessGroupSerializer { @Test @@ -54,19 +55,19 @@ public class TestJAXBVersionedProcessGroupSerializer { in.mark(1024); final int version = serializer.readDataModelVersion(in); - Assert.assertEquals(1, version); + assertEquals(1, version); in.reset(); final VersionedProcessGroup deserializedProcessGroup1 = serializer.deserialize(in); - Assert.assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier()); - Assert.assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName()); + assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier()); + assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName()); - Assert.assertEquals(1, deserializedProcessGroup1.getProcessors().size()); + assertEquals(1, deserializedProcessGroup1.getProcessors().size()); final VersionedProcessor deserializedProcessor1 = deserializedProcessGroup1.getProcessors().iterator().next(); - Assert.assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier()); - Assert.assertEquals(processor1.getName(), deserializedProcessor1.getName()); + assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier()); + assertEquals(processor1.getName(), deserializedProcessor1.getName()); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java index d9f5fd8c13..4cb10fbb7d 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java @@ -16,6 +16,8 @@ */ package org.apache.nifi.registry.service; +import org.apache.nifi.flow.VersionedProcessGroup; +import org.apache.nifi.flow.VersionedProcessor; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.db.entity.BucketEntity; import org.apache.nifi.registry.db.entity.FlowEntity; @@ -29,14 +31,11 @@ import org.apache.nifi.registry.flow.FlowPersistenceProvider; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.apache.nifi.flow.VersionedProcessGroup; -import org.apache.nifi.flow.VersionedProcessor; import org.apache.nifi.registry.serialization.FlowContent; import org.apache.nifi.registry.serialization.FlowContentSerializer; import org.apache.nifi.registry.service.alias.RegistryUrlAliasService; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -57,9 +56,10 @@ import java.util.Optional; import java.util.Set; import java.util.SortedSet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; @@ -81,7 +81,7 @@ public class TestRegistryService { private RegistryService registryService; - @Before + @BeforeEach public void setup() { metadataService = mock(MetadataService.class); flowPersistenceProvider = mock(FlowPersistenceProvider.class); @@ -119,7 +119,7 @@ public class TestRegistryService { assertEquals(bucket.getDescription(), createdBucket.getDescription()); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateBucketWithSameName() { final Bucket bucket = new Bucket(); bucket.setIdentifier("b2"); @@ -134,14 +134,14 @@ public class TestRegistryService { when(metadataService.getBucketsByName(bucket.getName())).thenReturn(Collections.singletonList(existingBucket)); // should throw exception since a bucket with the same name exists - registryService.createBucket(bucket); + assertThrows(IllegalStateException.class, () -> registryService.createBucket(bucket)); } - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateBucketWithMissingName() { final Bucket bucket = new Bucket(); when(metadataService.getBucketsByName(bucket.getName())).thenReturn(Collections.emptyList()); - registryService.createBucket(bucket); + assertThrows(ConstraintViolationException.class, () -> registryService.createBucket(bucket)); } @Test @@ -162,33 +162,33 @@ public class TestRegistryService { assertEquals(existingBucket.getCreated().getTime(), bucket.getCreatedTimestamp()); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testGetBucketDoesNotExist() { when(metadataService.getBucketById(any(String.class))).thenReturn(null); - registryService.getBucket("does-not-exist"); + assertThrows(ResourceNotFoundException.class, () -> registryService.getBucket("does-not-exist")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testUpdateBucketWithoutId() { final Bucket bucket = new Bucket(); bucket.setName("My Bucket"); bucket.setDescription("This is my bucket."); - registryService.updateBucket(bucket); + assertThrows(IllegalArgumentException.class, () -> registryService.updateBucket(bucket)); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testUpdateBucketDoesNotExist() { final Bucket bucket = new Bucket(); bucket.setIdentifier("b1"); bucket.setName("My Bucket"); bucket.setDescription("This is my bucket."); - registryService.updateBucket(bucket); + assertThrows(ResourceNotFoundException.class, () -> registryService.updateBucket(bucket)); when(metadataService.getBucketById(any(String.class))).thenReturn(null); - registryService.updateBucket(bucket); + assertThrows(ResourceNotFoundException.class, () -> registryService.updateBucket(bucket)); } - @Test(expected = IllegalStateException.class) + @Test public void testUpdateBucketWithSameNameAsExistingBucket() { final BucketEntity bucketToUpdate = new BucketEntity(); bucketToUpdate.setId("b1"); @@ -212,7 +212,7 @@ public class TestRegistryService { updatedBucket.setName("My Bucket #2"); updatedBucket.setDescription(bucketToUpdate.getDescription()); - registryService.updateBucket(updatedBucket); + assertThrows(IllegalStateException.class, () -> registryService.updateBucket(updatedBucket)); } @Test @@ -262,11 +262,11 @@ public class TestRegistryService { assertEquals(bucketToUpdate.getDescription(), result.getDescription()); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testDeleteBucketDoesNotExist() { final String bucketId = "b1"; when(metadataService.getBucketById(bucketId)).thenReturn(null); - registryService.deleteBucket(bucketId); + assertThrows(ResourceNotFoundException.class, () -> registryService.deleteBucket(bucketId)); } @Test @@ -300,13 +300,13 @@ public class TestRegistryService { // ---------------------- Test VersionedFlow methods --------------------------------------------- - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateFlowInvalid() { final VersionedFlow versionedFlow = new VersionedFlow(); - registryService.createFlow("b1", versionedFlow); + assertThrows(ConstraintViolationException.class, () -> registryService.createFlow("b1", versionedFlow)); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testCreateFlowBucketDoesNotExist() { when(metadataService.getBucketById(any(String.class))).thenReturn(null); @@ -316,10 +316,10 @@ public class TestRegistryService { versionedFlow.setName("My Flow"); versionedFlow.setBucketIdentifier("b1"); - registryService.createFlow(versionedFlow.getBucketIdentifier(), versionedFlow); + assertThrows(ResourceNotFoundException.class, () -> registryService.createFlow(versionedFlow.getBucketIdentifier(), versionedFlow)); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateFlowWithSameName() { final BucketEntity existingBucket = new BucketEntity(); existingBucket.setId("b1"); @@ -345,7 +345,7 @@ public class TestRegistryService { versionedFlow.setName(flowWithSameName.getName()); versionedFlow.setBucketIdentifier("b1"); - registryService.createFlow(versionedFlow.getBucketIdentifier(), versionedFlow); + assertThrows(IllegalStateException.class, () -> registryService.createFlow(versionedFlow.getBucketIdentifier(), versionedFlow)); } @Test @@ -376,16 +376,16 @@ public class TestRegistryService { assertEquals(versionedFlow.getDescription(), createdFlow.getDescription()); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testGetFlowDoesNotExist() { when(metadataService.getFlowById(any(String.class))).thenReturn(null); - registryService.getFlow("bucket1","flow1"); + assertThrows(ResourceNotFoundException.class, () -> registryService.getFlow("bucket1", "flow1")); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testGetFlowDirectDoesNotExist() { when(metadataService.getFlowById(any(String.class))).thenReturn(null); - registryService.getFlow("flow1"); + assertThrows(ResourceNotFoundException.class , () -> registryService.getFlow("flow1")); } @Test @@ -449,10 +449,10 @@ public class TestRegistryService { assertEquals(flowEntity.getModified().getTime(), versionedFlow.getModifiedTimestamp()); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testGetFlowsByBucketDoesNotExist() { when(metadataService.getBucketById(any(String.class))).thenReturn(null); - registryService.getFlows("b1"); + assertThrows(ResourceNotFoundException.class, () -> registryService.getFlows("b1")); } @Test @@ -492,13 +492,13 @@ public class TestRegistryService { assertEquals(2, allFlows.size()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testUpdateFlowWithoutId() { final VersionedFlow versionedFlow = new VersionedFlow(); - registryService.updateFlow(versionedFlow); + assertThrows(IllegalArgumentException.class, () -> registryService.updateFlow(versionedFlow)); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testUpdateFlowDoesNotExist() { final VersionedFlow versionedFlow = new VersionedFlow(); versionedFlow.setBucketIdentifier("b1"); @@ -506,10 +506,10 @@ public class TestRegistryService { when(metadataService.getFlowById(versionedFlow.getIdentifier())).thenReturn(null); - registryService.updateFlow(versionedFlow); + assertThrows(ResourceNotFoundException.class, () -> registryService.updateFlow(versionedFlow)); } - @Test(expected = IllegalStateException.class) + @Test public void testUpdateFlowWithSameNameAsExistingFlow() { final BucketEntity existingBucket = new BucketEntity(); existingBucket.setId("b1"); @@ -544,7 +544,7 @@ public class TestRegistryService { versionedFlow.setBucketIdentifier(existingBucket.getId()); versionedFlow.setName(otherFlow.getName()); - registryService.updateFlow(versionedFlow); + assertThrows(IllegalStateException.class, () -> registryService.updateFlow(versionedFlow)); } @Test @@ -590,10 +590,10 @@ public class TestRegistryService { assertEquals(flowToUpdate.getCreated().getTime(), updatedFlow.getCreatedTimestamp()); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testDeleteFlowDoesNotExist() { when(metadataService.getFlowById(any(String.class))).thenReturn(null); - registryService.deleteFlow("b1", "flow1"); + assertThrows(ResourceNotFoundException.class, () -> registryService.deleteFlow("b1", "flow1")); } @Test @@ -647,43 +647,43 @@ public class TestRegistryService { return snapshot; } - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateSnapshotInvalidMetadata() { final VersionedFlowSnapshot snapshot = createSnapshot(); snapshot.getSnapshotMetadata().setFlowIdentifier(null); - registryService.createFlowSnapshot(snapshot); + assertThrows(ConstraintViolationException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateSnapshotInvalidFlowContents() { final VersionedFlowSnapshot snapshot = createSnapshot(); snapshot.setFlowContents(null); - registryService.createFlowSnapshot(snapshot); + assertThrows(ConstraintViolationException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateSnapshotNullMetadata() { final VersionedFlowSnapshot snapshot = createSnapshot(); snapshot.setSnapshotMetadata(null); - registryService.createFlowSnapshot(snapshot); + assertThrows(ConstraintViolationException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = ConstraintViolationException.class) + @Test public void testCreateSnapshotNullFlowContents() { final VersionedFlowSnapshot snapshot = createSnapshot(); snapshot.setFlowContents(null); - registryService.createFlowSnapshot(snapshot); + assertThrows(ConstraintViolationException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testCreateSnapshotBucketDoesNotExist() { when(metadataService.getBucketById(any(String.class))).thenReturn(null); final VersionedFlowSnapshot snapshot = createSnapshot(); - registryService.createFlowSnapshot(snapshot); + assertThrows(ResourceNotFoundException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testCreateSnapshotFlowDoesNotExist() { final VersionedFlowSnapshot snapshot = createSnapshot(); @@ -697,10 +697,10 @@ public class TestRegistryService { when(metadataService.getFlowById(snapshot.getSnapshotMetadata().getFlowIdentifier())).thenReturn(null); - registryService.createFlowSnapshot(snapshot); + assertThrows(ResourceNotFoundException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateSnapshotVersionAlreadyExists() { final VersionedFlowSnapshot snapshot = createSnapshot(); @@ -734,10 +734,10 @@ public class TestRegistryService { final List existingSnapshots = Arrays.asList(existingSnapshot); when(metadataService.getSnapshots(existingFlow.getId())).thenReturn(existingSnapshots); - registryService.createFlowSnapshot(snapshot); + assertThrows(IllegalStateException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateSnapshotVersionNotNextVersion() { final VersionedFlowSnapshot snapshot = createSnapshot(); @@ -770,7 +770,7 @@ public class TestRegistryService { // set the version to something that is not the next one-up version snapshot.getSnapshotMetadata().setVersion(100); - registryService.createFlowSnapshot(snapshot); + assertThrows(IllegalStateException.class, () -> registryService.createFlowSnapshot(snapshot)); } @Test @@ -808,7 +808,7 @@ public class TestRegistryService { verify(metadataService, times(1)).createFlowSnapshot(any(FlowSnapshotEntity.class)); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateFirstSnapshotWithBadVersion() { final VersionedFlowSnapshot snapshot = createSnapshot(); @@ -833,10 +833,10 @@ public class TestRegistryService { // set the first version to something other than 1 snapshot.getSnapshotMetadata().setVersion(100); - registryService.createFlowSnapshot(snapshot); + assertThrows(IllegalStateException.class, () -> registryService.createFlowSnapshot(snapshot)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testCreateFirstSnapshotWithZeroVersion() { final VersionedFlowSnapshot snapshot = createSnapshot(); @@ -861,7 +861,7 @@ public class TestRegistryService { // set the first version to something other than 1 snapshot.getSnapshotMetadata().setVersion(0); - registryService.createFlowSnapshot(snapshot); + assertThrows(IllegalArgumentException.class, () -> registryService.createFlowSnapshot(snapshot)); } @Test @@ -1086,24 +1086,21 @@ public class TestRegistryService { when(metadataService.getLatestSnapshot(existingFlow.getId())).thenReturn(null); - try { - registryService.getLatestFlowSnapshotMetadata(existingBucket.getId(), existingFlow.getId()); - Assert.fail("Should have thrown exception"); - } catch (ResourceNotFoundException e) { - assertEquals("The specified flow ID has no versions", e.getMessage()); - } + ResourceNotFoundException e = assertThrows(ResourceNotFoundException.class, () -> registryService.getLatestFlowSnapshotMetadata(existingBucket.getId(), existingFlow.getId())); + assertEquals("The specified flow ID has no versions", e.getMessage()); + } - @Test(expected = ResourceNotFoundException.class) + @Test public void testGetSnapshotDoesNotExistInMetadataProvider() { final String bucketId = "b1"; final String flowId = "flow1"; final Integer version = 1; when(metadataService.getFlowSnapshot(flowId, version)).thenReturn(null); - registryService.getFlowSnapshot(bucketId, flowId, version); + assertThrows(ResourceNotFoundException.class, () -> registryService.getFlowSnapshot(bucketId, flowId, version)); } - @Test(expected = IllegalStateException.class) + @Test public void testGetSnapshotDoesNotExistInPersistenceProvider() { final BucketEntity existingBucket = createBucketEntity("b1"); final FlowEntity existingFlow = createFlowEntity(existingBucket.getId()); @@ -1126,7 +1123,7 @@ public class TestRegistryService { existingSnapshot.getVersion() )).thenReturn(null); - registryService.getFlowSnapshot(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion()); + assertThrows(IllegalStateException.class, () -> registryService.getFlowSnapshot(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion())); } @Test @@ -1180,13 +1177,13 @@ public class TestRegistryService { assertNotNull(bucket); } - @Test(expected = ResourceNotFoundException.class) + @Test public void testDeleteSnapshotDoesNotExist() { final String bucketId = "b1"; final String flowId = "flow1"; final Integer version = 1; when(metadataService.getFlowSnapshot(flowId, version)).thenReturn(null); - registryService.deleteFlowSnapshot(bucketId, flowId, version); + assertThrows(ResourceNotFoundException.class, () -> registryService.deleteFlowSnapshot(bucketId, flowId, version)); } @Test @@ -1260,14 +1257,14 @@ public class TestRegistryService { final VersionedProcessGroup pgB = createVersionedProcessGroupB(); when(flowContentSerializer.readDataModelVersion(any(InputStream.class))).thenReturn(2); when(flowContentSerializer.isProcessGroupVersion(eq(2))).thenReturn(true); - when(flowContentSerializer.deserializeProcessGroup(eq(2),any())).thenReturn(pgA, pgB); + when(flowContentSerializer.deserializeProcessGroup(eq(2), any())).thenReturn(pgA, pgB); final VersionedFlowDifference diff = registryService.getFlowDiff( "bucketIdentifier", "flowIdentifier", 1, 2); assertNotNull(diff); Optional removedComponent = diff.getComponentDifferenceGroups().stream() - .filter(p->p.getComponentId().equals("ID-pg1")).findFirst(); + .filter(p -> p.getComponentId().equals("ID-pg1")).findFirst(); assertTrue(removedComponent.isPresent()); assertTrue(removedComponent.get().getDifferences().iterator().next().getDifferenceType().equals("COMPONENT_REMOVED")); @@ -1283,20 +1280,20 @@ public class TestRegistryService { final VersionedProcessGroup pgB = createVersionedProcessGroupB(); when(flowContentSerializer.readDataModelVersion(any(InputStream.class))).thenReturn(2); when(flowContentSerializer.isProcessGroupVersion(eq(2))).thenReturn(true); - when(flowContentSerializer.deserializeProcessGroup(eq(2),any())).thenReturn(pgA, pgB); + when(flowContentSerializer.deserializeProcessGroup(eq(2), any())).thenReturn(pgA, pgB); // getFlowDiff orders the changes in ascending order of version number regardless of param order final VersionedFlowDifference diff = registryService.getFlowDiff( - "bucketIdentifier", "flowIdentifier", 2,1); + "bucketIdentifier", "flowIdentifier", 2, 1); assertNotNull(diff); Optional nameChangedComponent = diff.getComponentDifferenceGroups().stream() - .filter(p->p.getComponentId().equals("ProcessorFirstV1")).findFirst(); + .filter(p -> p.getComponentId().equals("ProcessorFirstV1")).findFirst(); assertTrue(nameChangedComponent.isPresent()); ComponentDifference nameChangeDifference = nameChangedComponent.get().getDifferences().stream() - .filter(d-> d.getDifferenceType().equals("NAME_CHANGED")).findFirst().get(); + .filter(d -> d.getDifferenceType().equals("NAME_CHANGED")).findFirst().get(); assertEquals("ProcessorFirstV1", nameChangeDifference.getValueA()); assertEquals("ProcessorFirstV2", nameChangeDifference.getValueB()); @@ -1310,22 +1307,23 @@ public class TestRegistryService { return root; } - private VersionedProcessGroup createProcessGroup(String identifier){ + private VersionedProcessGroup createProcessGroup(String identifier) { VersionedProcessGroup processGroup = new VersionedProcessGroup(); processGroup.setIdentifier(identifier); return processGroup; } + private VersionedProcessGroup createVersionedProcessGroupB() { VersionedProcessGroup updated = createVersionedProcessGroupA(); // remove a process group - updated.getProcessGroups().removeIf(pg->pg.getIdentifier().equals("ID-pg1")); + updated.getProcessGroups().removeIf(pg -> pg.getIdentifier().equals("ID-pg1")); // change the name of a processor - updated.getProcessors().stream().forEach(p->p.setPenaltyDuration(p.getName().equals("ProcessorFirstV1") ? "1" : "2")); - updated.getProcessors().stream().forEach(p->p.setName(p.getName().equals("ProcessorFirstV1") ? "ProcessorFirstV2" : p.getName())); + updated.getProcessors().stream().forEach(p -> p.setPenaltyDuration(p.getName().equals("ProcessorFirstV1") ? "1" : "2")); + updated.getProcessors().stream().forEach(p -> p.setName(p.getName().equals("ProcessorFirstV1") ? "ProcessorFirstV2" : p.getName())); return updated; } - private VersionedProcessor createVersionedProcessor(String name){ + private VersionedProcessor createVersionedProcessor(String name) { VersionedProcessor processor = new VersionedProcessor(); processor.setName(name); processor.setIdentifier(name); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/alias/RegistryUrlAliasServiceTest.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/alias/RegistryUrlAliasServiceTest.java index a1782c4565..414dab3b73 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/alias/RegistryUrlAliasServiceTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/alias/RegistryUrlAliasServiceTest.java @@ -17,12 +17,14 @@ package org.apache.nifi.registry.service.alias; import org.apache.nifi.registry.url.aliaser.generated.Alias; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class RegistryUrlAliasServiceTest { private static Alias createAlias(String internal, String external) { @@ -42,9 +44,9 @@ public class RegistryUrlAliasServiceTest { assertEquals(url, aliaser.getInternal(url)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testMalformedExternal() { - new RegistryUrlAliasService(Collections.singletonList(createAlias("https://registry.com:18080", "registry.com:18080"))); + assertThrows(IllegalArgumentException.class, () -> new RegistryUrlAliasService(Collections.singletonList(createAlias("https://registry.com:18080", "registry.com:18080")))); } @Test @@ -160,12 +162,12 @@ public class RegistryUrlAliasServiceTest { assertEquals(external, aliaser.getExternal(internal2)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testDuplicateInternalTokens() { String internal = "THIS_NIFI_REGISTRY"; String external1 = "http://localhost:18080"; String external2 = "http://localhost:18081"; - new RegistryUrlAliasService(Arrays.asList(createAlias(internal, external1), createAlias(internal, external2))); + assertThrows(IllegalArgumentException.class, () -> new RegistryUrlAliasService(Arrays.asList(createAlias(internal, external1), createAlias(internal, external2)))); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/extension/docs/TestHtmlExtensionDocWriter.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/extension/docs/TestHtmlExtensionDocWriter.java index 9b93c8f68c..2d91d7720f 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/extension/docs/TestHtmlExtensionDocWriter.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/extension/docs/TestHtmlExtensionDocWriter.java @@ -25,8 +25,8 @@ import org.apache.nifi.registry.serialization.ExtensionSerializer; import org.apache.nifi.registry.serialization.Serializer; import org.apache.nifi.registry.serialization.jackson.ObjectMapperProvider; import org.apache.nifi.registry.service.mapper.ExtensionMappings; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.File; @@ -43,7 +43,7 @@ public class TestHtmlExtensionDocWriter { private ExtensionDocWriter docWriter; private Serializer extensionSerializer; - @Before + @BeforeEach public void setup() { docWriter = new HtmlExtensionDocWriter(); extensionSerializer = new ExtensionSerializer(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/BucketsIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/BucketsIT.java index 2892d030a3..ba5cf40b81 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/BucketsIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/BucketsIT.java @@ -18,7 +18,7 @@ package org.apache.nifi.registry.web.api; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.jdbc.Sql; @@ -30,9 +30,9 @@ import javax.ws.rs.core.Response; import java.util.UUID; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertBucketsEqual; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BucketsIT extends UnsecuredITBase { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/DBFlowStorageIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/DBFlowStorageIT.java index 658a5edb5d..29337b225b 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/DBFlowStorageIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/DBFlowStorageIT.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.registry.web.api; +import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.NiFiRegistryTestApiApplication; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.client.NiFiRegistryClient; @@ -25,25 +26,24 @@ import org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.io.IOException; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( classes = NiFiRegistryTestApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -55,7 +55,7 @@ public class DBFlowStorageIT extends IntegrationTestBase { private NiFiRegistryClient client; - @Before + @BeforeEach public void setup() throws IOException { final String baseUrl = createBaseURL(); LOGGER.info("Using base url = " + baseUrl); @@ -72,7 +72,7 @@ public class DBFlowStorageIT extends IntegrationTestBase { this.client = client; } - @After + @AfterEach public void teardown() { try { client.close(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java index 9493522ea9..d2ccbf90d2 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java @@ -16,15 +16,13 @@ */ package org.apache.nifi.registry.web.api; -import java.io.File; +import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.bucket.BucketItemType; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.jdbc.Sql; @@ -34,15 +32,17 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.File; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertBucketsEqual; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertFlowSnapshotMetadataEqual; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertFlowSnapshotsEqual; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertFlowsEqual; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; @Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:db/clearDB.sql", "classpath:db/FlowsIT.sql"}) public class FlowsIT extends UnsecuredITBase { @@ -72,7 +72,7 @@ public class FlowsIT extends UnsecuredITBase { // NOTE: The tests that seed the DB directly from SQL end up with different results for the timestamp depending on // which DB is used, so for now these types of tests only run against H2. @Test - @IfProfileValue(name="current.database.is.h2", value="true") + @IfProfileValue(name = "current.database.is.h2", value = "true") public void testGetFlows() throws Exception { // Given: a few buckets and flows have been populated in the DB (see FlowsIT.sql) @@ -365,7 +365,7 @@ public class FlowsIT extends UnsecuredITBase { // NOTE: The tests that seed the DB directly from SQL end up with different results for the timestamp depending on // which DB is used, so for now these types of tests only run against H2. @Test - @IfProfileValue(name="current.database.is.h2", value="true") + @IfProfileValue(name = "current.database.is.h2", value = "true") public void testGetFlowVersions() throws Exception { // Given: a bucket "1" with flow "1" with existing snapshots has been populated in the DB (see FlowsIT.sql) @@ -532,17 +532,15 @@ public class FlowsIT extends UnsecuredITBase { // saving the flow to bucket 1 should not work because there is a flow with the same name flow.setBucketIdentifier("1"); - try { - client.target(createURL("buckets/1/flows")) - .resolveTemplate("bucketId", bucketId) - .request() - .post(Entity.entity(flow, MediaType.APPLICATION_JSON), VersionedFlow.class); - Assert.fail("Should have thrown exception"); - } catch (WebApplicationException e) { - final String errorMessage = e.getResponse().readEntity(String.class); - Assert.assertEquals("A versioned flow with the same name already exists in the selected bucket", errorMessage); - } + WebApplicationException e = assertThrows(WebApplicationException.class, () -> client.target(createURL("buckets/1/flows")) + .resolveTemplate("bucketId", bucketId) + .request() + .post(Entity.entity(flow, MediaType.APPLICATION_JSON), VersionedFlow.class)); + + final String errorMessage = e.getResponse().readEntity(String.class); + assertEquals("A versioned flow with the same name already exists in the selected bucket", errorMessage); + } @@ -606,10 +604,10 @@ public class FlowsIT extends UnsecuredITBase { // GET the versioned Flow that was just imported final VersionedFlowSnapshotMetadata[] versionedFlowSnapshots = client - .target(createURL("buckets/{bucketId}/flows/{flowId}/versions")) - .resolveTemplate("bucketId", bucketId) - .resolveTemplate("flowId", flowId) - .request().get(VersionedFlowSnapshotMetadata[].class); + .target(createURL("buckets/{bucketId}/flows/{flowId}/versions")) + .resolveTemplate("bucketId", bucketId) + .resolveTemplate("flowId", flowId) + .request().get(VersionedFlowSnapshotMetadata[].class); assertNotNull(versionedFlowSnapshots); assertEquals(2, versionedFlowSnapshots.length); assertFlowSnapshotMetadataEqual(importedFlowSnapshot.getSnapshotMetadata(), versionedFlowSnapshots[0], true); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/NoRevisionsIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/NoRevisionsIT.java index 67db462df9..0dad20847d 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/NoRevisionsIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/NoRevisionsIT.java @@ -21,7 +21,7 @@ import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; import org.apache.nifi.flow.VersionedProcessGroup; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; @@ -31,8 +31,8 @@ import java.util.UUID; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertBucketsEqual; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertFlowSnapshotsEqual; import static org.apache.nifi.registry.web.api.IntegrationTestUtils.assertFlowsEqual; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class NoRevisionsIT extends UnsecuredNoRevisionsITBase { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureDatabaseIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureDatabaseIT.java index 3b7ce608d5..a37c85fa45 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureDatabaseIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureDatabaseIT.java @@ -30,27 +30,26 @@ import org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient; import org.apache.nifi.registry.revision.entity.RevisionInfo; import org.apache.nifi.registry.security.authorization.RequestAction; import org.apache.nifi.registry.security.authorization.resource.ResourceFactory; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( classes = NiFiRegistryTestApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -66,22 +65,22 @@ public class SecureDatabaseIT extends IntegrationTestBase { private NiFiRegistryClient client; - @Before + @BeforeEach public void setup() { final String baseUrl = createBaseURL(); LOGGER.info("Using base url = " + baseUrl); final NiFiRegistryClientConfig clientConfig = createClientConfig(baseUrl); - Assert.assertNotNull(clientConfig); + assertNotNull(clientConfig); final NiFiRegistryClient client = new JerseyNiFiRegistryClient.Builder() .config(clientConfig) .build(); - Assert.assertNotNull(client); + assertNotNull(client); this.client = client; } - @After + @AfterEach public void teardown() { try { client.close(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureFileIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureFileIT.java index 7f812156fa..13a62511c2 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureFileIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureFileIT.java @@ -22,22 +22,21 @@ import org.apache.nifi.registry.authorization.Tenant; import org.apache.nifi.registry.authorization.User; import org.apache.nifi.registry.authorization.UserGroup; import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Deploy the Web API Application using an embedded Jetty Server for local integration testing, with the follow characteristics: @@ -47,7 +46,7 @@ import static org.junit.Assert.assertNotNull; * - The database is embed H2 using volatile (in-memory) persistence * - Custom SQL is clearing the DB before each test method by default, unless method overrides this behavior */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( classes = NiFiRegistryTestApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureKerberosIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureKerberosIT.java index de87fcf1a9..1c37eaf9f8 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureKerberosIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureKerberosIT.java @@ -19,9 +19,9 @@ package org.apache.nifi.registry.web.api; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.registry.NiFiRegistryTestApiApplication; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; @@ -33,7 +33,7 @@ import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.kerberos.authentication.KerberosTicketValidation; import org.springframework.security.kerberos.authentication.KerberosTicketValidator; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.ws.rs.core.Response; import java.io.UnsupportedEncodingException; @@ -41,9 +41,9 @@ import java.nio.charset.Charset; import java.util.Arrays; import java.util.Base64; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Deploy the Web API Application using an embedded Jetty Server for local integration testing, with the follow characteristics: @@ -53,7 +53,7 @@ import static org.junit.Assert.assertTrue; * - The database is embed H2 using volatile (in-memory) persistence * - Custom SQL is clearing the DB before each test method by default, unless method overrides this behavior */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "spring.profiles.include=ITSecureKerberos") @@ -102,7 +102,7 @@ public class SecureKerberosIT extends IntegrationTestBase { private String adminAuthToken; - @Before + @BeforeEach public void generateAuthToken() { String validTicket = new String(Base64.getEncoder().encode(validKerberosTicket.getBytes(Charset.forName("UTF-8")))); final String token = client diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureNiFiRegistryClientIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureNiFiRegistryClientIT.java index 7e47999268..80b8b01297 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureNiFiRegistryClientIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureNiFiRegistryClientIT.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.registry.web.api; +import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.NiFiRegistryTestApiApplication; import org.apache.nifi.registry.authorization.CurrentUser; import org.apache.nifi.registry.authorization.Permissions; @@ -36,19 +37,17 @@ import org.apache.nifi.registry.client.impl.request.ProxiedEntityRequestConfig; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.ws.rs.ForbiddenException; import java.io.IOException; @@ -60,7 +59,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( classes = NiFiRegistryTestApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -76,22 +75,22 @@ public class SecureNiFiRegistryClientIT extends IntegrationTestBase { private NiFiRegistryClient client; - @Before + @BeforeEach public void setup() { final String baseUrl = createBaseURL(); LOGGER.info("Using base url = " + baseUrl); final NiFiRegistryClientConfig clientConfig = createClientConfig(baseUrl); - Assert.assertNotNull(clientConfig); + assertNotNull(clientConfig); final NiFiRegistryClient client = new JerseyNiFiRegistryClient.Builder() .config(clientConfig) .build(); - Assert.assertNotNull(client); + assertNotNull(client); this.client = client; } - @After + @AfterEach public void teardown() { try { client.close(); @@ -129,7 +128,7 @@ public class SecureNiFiRegistryClientIT extends IntegrationTestBase { assertNotNull(createdBucket.getRevision()); final List buckets = bucketClient.getAll(); - Assert.assertEquals(4, buckets.size()); + assertEquals(4, buckets.size()); buckets.forEach(b -> assertNotNull(b.getRevision())); final VersionedFlow flow = new VersionedFlow(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureProxyIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureProxyIT.java index 0401eceec9..72f6a38a1a 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureProxyIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/SecureProxyIT.java @@ -25,27 +25,26 @@ import org.apache.nifi.registry.client.RequestConfig; import org.apache.nifi.registry.client.UserClient; import org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient; import org.apache.nifi.registry.client.impl.request.ProxiedEntityRequestConfig; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.skyscreamer.jsonassert.JSONAssert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( classes = NiFiRegistryTestApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -64,22 +63,22 @@ public class SecureProxyIT extends IntegrationTestBase { private NiFiRegistryClient registryClient; - @Before + @BeforeEach public void setup() { final String baseUrl = createBaseURL(); LOGGER.info("Using base url = " + baseUrl); final NiFiRegistryClientConfig clientConfig = createClientConfig(baseUrl); - Assert.assertNotNull(clientConfig); + assertNotNull(clientConfig); final NiFiRegistryClient client = new JerseyNiFiRegistryClient.Builder() .config(clientConfig) .build(); - Assert.assertNotNull(client); + assertNotNull(client); this.registryClient = client; } - @After + @AfterEach public void teardown() { try { registryClient.close(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/TenantResourceTest.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/TenantResourceTest.java index 99350bb738..1c8665092d 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/TenantResourceTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/TenantResourceTest.java @@ -24,8 +24,8 @@ import org.apache.nifi.registry.revision.entity.RevisionInfo; import org.apache.nifi.registry.revision.web.ClientIdParameter; import org.apache.nifi.registry.revision.web.LongParameter; import org.apache.nifi.registry.web.service.ServiceFacade; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.servlet.http.HttpServletRequest; import java.net.URI; @@ -43,7 +43,7 @@ public class TenantResourceTest { private EventService eventService; private ServiceFacade serviceFacade; - @Before + @BeforeEach public void setUp() { eventService = mock(EventService.class); serviceFacade = mock(ServiceFacade.class); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java index 64c714800c..83ff24506f 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/UnsecuredNiFiRegistryClientIT.java @@ -74,9 +74,9 @@ import org.apache.nifi.registry.revision.entity.RevisionInfo; import org.apache.nifi.registry.util.FileUtils; import org.bouncycastle.util.encoders.Hex; import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -103,11 +103,12 @@ import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test all basic functionality of JerseyNiFiRegistryClient. @@ -120,7 +121,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { private NiFiRegistryClient client; - @Before + @BeforeEach public void setup() { final String baseUrl = createBaseURL(); LOGGER.info("Using base url = " + baseUrl); @@ -149,7 +150,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { } } - @After + @AfterEach public void teardown() { try { client.close(); @@ -183,7 +184,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { final int numBuckets = 10; final List createdBuckets = new ArrayList<>(); - for (int i=0; i < numBuckets; i++) { + for (int i = 0; i < numBuckets; i++) { final Bucket createdBucket = createBucket(bucketClient, i); LOGGER.info("Created bucket # " + i + " with id " + createdBucket.getIdentifier()); createdBuckets.add(createdBucket); @@ -346,13 +347,8 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { assertEquals(2, latestMetadata.getVersion()); // get latest metadata that doesn't exist - try { - snapshotClient.getLatestMetadata(snapshotFlow.getBucketIdentifier(), "DOES-NOT-EXIST"); - fail("Should have thrown exception"); - } catch (NiFiRegistryException nfe) { - assertEquals("Error retrieving latest snapshot metadata: The specified flow ID does not exist in this bucket.", nfe.getMessage()); - } - + NiFiRegistryException nfe = assertThrows(NiFiRegistryException.class, () -> snapshotClient.getLatestMetadata(snapshotFlow.getBucketIdentifier(), "DOES-NOT-EXIST")); + assertEquals("Error retrieving latest snapshot metadata: The specified flow ID does not exist in this bucket.", nfe.getMessage()); // get latest metadata without bucket final VersionedFlowSnapshotMetadata latestMetadataWithoutBucket = snapshotClient.getLatestMetadata(snapshotFlow.getIdentifier()); assertNotNull(latestMetadataWithoutBucket); @@ -708,7 +704,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { assertNotNull(tc.getTag()); }); - final ExtensionMetadataContainer allExtensions = extensionClient.findExtensions((ExtensionFilterParams)null); + final ExtensionMetadataContainer allExtensions = extensionClient.findExtensions((ExtensionFilterParams) null); assertNotNull(allExtensions); assertNotNull(allExtensions.getExtensions()); assertEquals(4, allExtensions.getNumResults()); @@ -871,7 +867,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { context1.setName("Parameter Context 1"); context1.setParameters(new HashSet<>(Arrays.asList(param1, param2))); - final Map contexts = new HashMap<>(); + final Map contexts = new HashMap<>(); contexts.put(context1.getName(), context1); // Create an external controller service reference @@ -888,7 +884,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { final Map parameterProviderReferences = new HashMap<>(); parameterProviderReferences.put(parameterProviderReference.getIdentifier(), parameterProviderReference); - final Map serviceReferences = new HashMap<>(); + final Map serviceReferences = new HashMap<>(); serviceReferences.put(serviceReference.getIdentifier(), serviceReference); // Create the snapshot @@ -1019,7 +1015,7 @@ public class UnsecuredNiFiRegistryClientIT extends UnsecuredITBase { subProcessGroup.setName("Sub Process Group"); rootProcessGroup.getProcessGroups().add(subProcessGroup); - final Map processorProperties = new HashMap<>(); + final Map processorProperties = new HashMap<>(); processorProperties.put("Prop 1", "Val 1"); processorProperties.put("Prop 2", "Val 2"); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/link/TestLinkService.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/link/TestLinkService.java index 4242c4d742..e82a5dbafb 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/link/TestLinkService.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/link/TestLinkService.java @@ -16,13 +16,13 @@ */ package org.apache.nifi.registry.web.link; +import org.apache.nifi.extension.ExtensionMetadata; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.bucket.BucketItem; import org.apache.nifi.registry.bucket.BucketItemType; import org.apache.nifi.registry.extension.bundle.Bundle; import org.apache.nifi.registry.extension.bundle.BundleInfo; import org.apache.nifi.registry.extension.bundle.BundleVersionMetadata; -import org.apache.nifi.extension.ExtensionMetadata; import org.apache.nifi.registry.extension.repo.ExtensionRepoArtifact; import org.apache.nifi.registry.extension.repo.ExtensionRepoBucket; import org.apache.nifi.registry.extension.repo.ExtensionRepoExtensionMetadata; @@ -30,15 +30,17 @@ import org.apache.nifi.registry.extension.repo.ExtensionRepoGroup; import org.apache.nifi.registry.extension.repo.ExtensionRepoVersionSummary; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.UriBuilder; import java.net.URI; import java.util.ArrayList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class TestLinkService { private static final String BASE_URI = "http://localhost:18080/nifi-registry-api"; @@ -61,7 +63,7 @@ public class TestLinkService { private List extensionRepoVersions; private List extensionRepoExtensionMetadata; - @Before + @BeforeEach public void setup() { linkService = new LinkService(); @@ -224,60 +226,60 @@ public class TestLinkService { @Test public void testPopulateBucketLinks() { - buckets.forEach(b -> Assert.assertNull(b.getLink())); + buckets.forEach(b -> assertNull(b.getLink())); linkService.populateLinks(buckets); - buckets.forEach(b -> Assert.assertEquals( + buckets.forEach(b -> assertEquals( "buckets/" + b.getIdentifier(), b.getLink().getUri().toString())); } @Test public void testPopulateFlowLinks() { - flows.forEach(f -> Assert.assertNull(f.getLink())); + flows.forEach(f -> assertNull(f.getLink())); linkService.populateLinks(flows); - flows.forEach(f -> Assert.assertEquals( + flows.forEach(f -> assertEquals( "buckets/" + f.getBucketIdentifier() + "/flows/" + f.getIdentifier(), f.getLink().getUri().toString())); } @Test public void testPopulateSnapshotLinks() { - snapshots.forEach(s -> Assert.assertNull(s.getLink())); + snapshots.forEach(s -> assertNull(s.getLink())); linkService.populateLinks(snapshots); - snapshots.forEach(s -> Assert.assertEquals( + snapshots.forEach(s -> assertEquals( "buckets/" + s.getBucketIdentifier() + "/flows/" + s.getFlowIdentifier() + "/versions/" + s.getVersion(), s.getLink().getUri().toString())); } @Test public void testPopulateItemLinks() { - items.forEach(i -> Assert.assertNull(i.getLink())); + items.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(items); items.forEach(i -> { if (i.getType() == BucketItemType.Flow) { - Assert.assertEquals("buckets/" + i.getBucketIdentifier() + "/flows/" + i.getIdentifier(), i.getLink().getUri().toString()); + assertEquals("buckets/" + i.getBucketIdentifier() + "/flows/" + i.getIdentifier(), i.getLink().getUri().toString()); } else { - Assert.assertEquals("bundles/" + i.getIdentifier(), i.getLink().getUri().toString()); + assertEquals("bundles/" + i.getIdentifier(), i.getLink().getUri().toString()); } }); } @Test public void testPopulateExtensionBundleLinks() { - bundles.forEach(i -> Assert.assertNull(i.getLink())); + bundles.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(bundles); - bundles.forEach(eb -> Assert.assertEquals("bundles/" + eb.getIdentifier(), eb.getLink().getUri().toString())); + bundles.forEach(eb -> assertEquals("bundles/" + eb.getIdentifier(), eb.getLink().getUri().toString())); } @Test public void testPopulateExtensionBundleVersionLinks() { - bundleVersionMetadata.forEach(i -> Assert.assertNull(i.getLink())); + bundleVersionMetadata.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(bundleVersionMetadata); - bundleVersionMetadata.forEach(eb -> Assert.assertEquals( + bundleVersionMetadata.forEach(eb -> assertEquals( "bundles/" + eb.getBundleId() + "/versions/" + eb.getVersion(), eb.getLink().getUri().toString())); } @Test public void testPopulateExtensionBundleVersionExtensionMetadataLinks() { - extensionMetadata.forEach(i -> Assert.assertNull(i.getLink())); - extensionMetadata.forEach(i -> Assert.assertNull(i.getLinkDocs())); + extensionMetadata.forEach(i -> assertNull(i.getLink())); + extensionMetadata.forEach(i -> assertNull(i.getLinkDocs())); linkService.populateLinks(extensionMetadata); @@ -285,16 +287,16 @@ public class TestLinkService { final String extensionUri = "bundles/" + e.getBundleInfo().getBundleId() + "/versions/" + e.getBundleInfo().getVersion() + "/extensions/" + e.getName(); - Assert.assertEquals(extensionUri, e.getLink().getUri().toString()); - Assert.assertEquals(extensionUri + "/docs", e.getLinkDocs().getUri().toString()); + assertEquals(extensionUri, e.getLink().getUri().toString()); + assertEquals(extensionUri + "/docs", e.getLinkDocs().getUri().toString()); }); } @Test public void testPopulateExtensionRepoBucketLinks() { - extensionRepoBuckets.forEach(i -> Assert.assertNull(i.getLink())); + extensionRepoBuckets.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(extensionRepoBuckets); - extensionRepoBuckets.forEach(i -> Assert.assertEquals( + extensionRepoBuckets.forEach(i -> assertEquals( "extension-repository/" + i.getBucketName(), i.getLink().getUri().toString()) ); @@ -302,10 +304,10 @@ public class TestLinkService { @Test public void testPopulateExtensionRepoGroupLinks() { - extensionRepoGroups.forEach(i -> Assert.assertNull(i.getLink())); + extensionRepoGroups.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(extensionRepoGroups); extensionRepoGroups.forEach(i -> { - Assert.assertEquals( + assertEquals( "extension-repository/" + i.getBucketName() + "/" + i.getGroupId(), i.getLink().getUri().toString()); } ); @@ -313,10 +315,10 @@ public class TestLinkService { @Test public void testPopulateExtensionRepoArtifactLinks() { - extensionRepoArtifacts.forEach(i -> Assert.assertNull(i.getLink())); + extensionRepoArtifacts.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(extensionRepoArtifacts); extensionRepoArtifacts.forEach(i -> { - Assert.assertEquals( + assertEquals( "extension-repository/" + i.getBucketName() + "/" + i.getGroupId() + "/" + i.getArtifactId(), i.getLink().getUri().toString()); } ); @@ -324,10 +326,10 @@ public class TestLinkService { @Test public void testPopulateExtensionRepoVersionLinks() { - extensionRepoVersions.forEach(i -> Assert.assertNull(i.getLink())); + extensionRepoVersions.forEach(i -> assertNull(i.getLink())); linkService.populateLinks(extensionRepoVersions); extensionRepoVersions.forEach(i -> { - Assert.assertEquals( + assertEquals( "extension-repository/" + i.getBucketName() + "/" + i.getGroupId() + "/" + i.getArtifactId() + "/" + i.getVersion(), i.getLink().getUri().toString()); } ); @@ -335,10 +337,10 @@ public class TestLinkService { @Test public void testPopulateExtensionRepoVersionFullLinks() { - extensionRepoVersions.forEach(i -> Assert.assertNull(i.getLink())); + extensionRepoVersions.forEach(i -> assertNull(i.getLink())); linkService.populateFullLinks(extensionRepoVersions, baseUri); extensionRepoVersions.forEach(i -> { - Assert.assertEquals( + assertEquals( BASE_URI + "/extension-repository/" + i.getBucketName() + "/" + i.getGroupId() + "/" + i.getArtifactId() + "/" + i.getVersion(), i.getLink().getUri().toString()); } ); @@ -346,16 +348,16 @@ public class TestLinkService { @Test public void testPopulateExtensionRepoExtensionMetdataFullLinks() { - extensionRepoExtensionMetadata.forEach(i -> Assert.assertNull(i.getLink())); - extensionRepoExtensionMetadata.forEach(i -> Assert.assertNull(i.getLinkDocs())); + extensionRepoExtensionMetadata.forEach(i -> assertNull(i.getLink())); + extensionRepoExtensionMetadata.forEach(i -> assertNull(i.getLinkDocs())); linkService.populateFullLinks(extensionRepoExtensionMetadata, baseUri); extensionRepoExtensionMetadata.forEach(i -> { final BundleInfo bi = i.getExtensionMetadata().getBundleInfo(); final String extensionUri = BASE_URI + "/extension-repository/" + bi.getBucketName() + "/" + bi.getGroupId() + "/" + bi.getArtifactId() + "/" + bi.getVersion() + "/extensions/" + i.getExtensionMetadata().getName(); - Assert.assertEquals(extensionUri, i.getLink().getUri().toString()); - Assert.assertEquals(extensionUri + "/docs", i.getLinkDocs().getUri().toString()); + assertEquals(extensionUri, i.getLink().getUri().toString()); + assertEquals(extensionUri + "/docs", i.getLinkDocs().getUri().toString()); }); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcServiceTest.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcServiceTest.java index 2b3b2d08ff..adcf0bc16c 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcServiceTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcServiceTest.java @@ -19,16 +19,17 @@ package org.apache.nifi.registry.web.security.authentication.oidc; import com.nimbusds.oauth2.sdk.AuthorizationCode; import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant; import com.nimbusds.oauth2.sdk.id.State; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.UUID; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -38,23 +39,23 @@ public class OidcServiceTest { public static final String TEST_REQUEST_IDENTIFIER = "test-request-identifier"; public static final String TEST_STATE = "test-state"; - @Test(expected = IllegalStateException.class) + @Test public void testOidcNotEnabledCreateState() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); - service.createState(TEST_REQUEST_IDENTIFIER); + assertThrows(IllegalStateException.class, () -> service.createState(TEST_REQUEST_IDENTIFIER)); } - @Test(expected = IllegalStateException.class) + @Test public void testCreateStateMultipleInvocations() throws Exception { final OidcService service = getServiceWithOidcSupport(); service.createState(TEST_REQUEST_IDENTIFIER); - service.createState(TEST_REQUEST_IDENTIFIER); + assertThrows(IllegalStateException.class, () -> service.createState(TEST_REQUEST_IDENTIFIER)); } - @Test(expected = IllegalStateException.class) + @Test public void testOidcNotEnabledValidateState() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); - service.isStateValid(TEST_REQUEST_IDENTIFIER, new State(TEST_STATE)); + assertThrows(IllegalStateException.class, () -> service.isStateValid(TEST_REQUEST_IDENTIFIER, new State(TEST_STATE))); } @Test @@ -80,23 +81,23 @@ public class OidcServiceTest { assertFalse(service.isStateValid(TEST_REQUEST_IDENTIFIER, state)); } - @Test(expected = IllegalStateException.class) + @Test public void testOidcNotEnabledExchangeCode() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); - service.exchangeAuthorizationCodeForLoginAuthenticationToken(TEST_REQUEST_IDENTIFIER, getAuthorizationCodeGrant()); + assertThrows(IllegalStateException.class, () -> service.exchangeAuthorizationCodeForLoginAuthenticationToken(TEST_REQUEST_IDENTIFIER, getAuthorizationCodeGrant())); } - @Test(expected = IllegalStateException.class) + @Test public void testExchangeCodeMultipleInvocation() throws Exception { final OidcService service = getServiceWithOidcSupport(); service.exchangeAuthorizationCodeForLoginAuthenticationToken(TEST_REQUEST_IDENTIFIER, getAuthorizationCodeGrant()); - service.exchangeAuthorizationCodeForLoginAuthenticationToken(TEST_REQUEST_IDENTIFIER, getAuthorizationCodeGrant()); + assertThrows(IllegalStateException.class, () -> service.exchangeAuthorizationCodeForLoginAuthenticationToken(TEST_REQUEST_IDENTIFIER, getAuthorizationCodeGrant())); } - @Test(expected = IllegalStateException.class) + @Test public void testOidcNotEnabledGetJwt() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); - service.getJwt(TEST_REQUEST_IDENTIFIER); + assertThrows(IllegalStateException.class, () -> service.getJwt(TEST_REQUEST_IDENTIFIER)); } @Test diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/StandardOidcIdentityProviderTest.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/StandardOidcIdentityProviderTest.java index c0b496fec0..ce66127506 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/StandardOidcIdentityProviderTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/security/authentication/oidc/StandardOidcIdentityProviderTest.java @@ -19,14 +19,14 @@ package org.apache.nifi.registry.web.security.authentication.oidc; import com.nimbusds.oauth2.sdk.Scope; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.nifi.registry.properties.NiFiRegistryProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucket.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucket.java index 31d7315e59..386d889242 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucket.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucket.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -34,8 +34,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITCreateBucket { private WebDriver driver; @@ -44,7 +44,7 @@ public class ITCreateBucket { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -95,7 +95,7 @@ public class ITCreateBucket { assertEquals(1, bucketCount.size()); } - @After + @AfterEach public void tearDown() throws Exception { // bucket cleanup diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucketCancel.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucketCancel.java index f23fdf2257..07cc9fc65d 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucketCancel.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateBucketCancel.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.NoAlertPresentException; @@ -31,7 +31,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import io.github.bonigarcia.wdm.WebDriverManager; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class ITCreateBucketCancel { private WebDriver driver; @@ -40,7 +40,7 @@ public class ITCreateBucketCancel { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -91,7 +91,7 @@ public class ITCreateBucketCancel { } - @After + @AfterEach public void tearDown() throws Exception { driver.quit(); String verificationErrorString = verificationErrors.toString(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateDuplicateBucket.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateDuplicateBucket.java index 79de5ae034..ef53a39b4e 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateDuplicateBucket.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateDuplicateBucket.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -35,8 +35,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITCreateDuplicateBucket { private WebDriver driver; @@ -45,7 +45,7 @@ public class ITCreateDuplicateBucket { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -141,7 +141,7 @@ public class ITCreateDuplicateBucket { assertEquals(1, bucketCount.size()); } - @After + @AfterEach public void tearDown() throws Exception { // bucket cleanup diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateMultipleBuckets.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateMultipleBuckets.java index c9011abe46..40ca400363 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateMultipleBuckets.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITCreateMultipleBuckets.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -34,8 +34,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITCreateMultipleBuckets { private WebDriver driver; @@ -44,7 +44,7 @@ public class ITCreateMultipleBuckets { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -127,7 +127,7 @@ public class ITCreateMultipleBuckets { } - @After + @AfterEach public void tearDown() throws Exception { // bucket cleanup diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucket.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucket.java index c9980d5c7e..7f3b98cce7 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucket.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucket.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.NoAlertPresentException; @@ -33,8 +33,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITDeleteSingleBucket { private WebDriver driver; @@ -43,7 +43,7 @@ public class ITDeleteSingleBucket { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -117,7 +117,7 @@ public class ITDeleteSingleBucket { wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("[data-automation-id='no-buckets-message']"))); } - @After + @AfterEach public void tearDown() throws Exception { driver.quit(); String verificationErrorString = verificationErrors.toString(); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucketCancel.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucketCancel.java index 4d2863dfdd..bcdc90c188 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucketCancel.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITDeleteSingleBucketCancel.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -34,8 +34,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITDeleteSingleBucketCancel { private WebDriver driver; @@ -44,7 +44,7 @@ public class ITDeleteSingleBucketCancel { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -116,7 +116,7 @@ public class ITDeleteSingleBucketCancel { assertEquals(1, bucketCount.size()); } - @After + @AfterEach public void tearDown() throws Exception { // bucket cleanup diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucket.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucket.java index 66773eb19d..982f72eaea 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucket.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucket.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -35,8 +35,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITRenameBucket { private WebDriver driver; @@ -45,7 +45,7 @@ public class ITRenameBucket { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -132,7 +132,7 @@ public class ITRenameBucket { assertEquals(1, bucketCount.size()); } - @After + @AfterEach public void tearDown() throws Exception { // wait for side nav to close wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("mat-sidenav"))); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucketDuplicate.java b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucketDuplicate.java index a66f6d5423..7130dfaf00 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucketDuplicate.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-ui/src/test/java/org/apache/nifi/registry/ui/ITRenameBucketDuplicate.java @@ -17,9 +17,9 @@ package org.apache.nifi.registry.ui; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -35,8 +35,8 @@ import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ITRenameBucketDuplicate { private WebDriver driver; @@ -45,7 +45,7 @@ public class ITRenameBucketDuplicate { private WebDriverWait wait; private StringBuffer verificationErrors = new StringBuffer(); - @Before + @BeforeEach public void setUp() throws Exception { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); @@ -180,7 +180,7 @@ public class ITRenameBucketDuplicate { assertEquals(2, bucketCount.size()); } - @After + @AfterEach public void tearDown() throws Exception { // wait for side nav to close wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("mat-sidenav")));