mirror of https://github.com/apache/nifi.git
NIFI-10293 Refactored tests in nifi-jolt-transform-json-ui to use JUnit 5
This closes #6258 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
ded48269fe
commit
b260c10ad4
|
@ -30,7 +30,7 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory;
|
||||
import org.glassfish.jersey.test.spi.TestContainerFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.AdditionalMatchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
@ -42,9 +42,9 @@ import javax.ws.rs.core.Response;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -129,12 +129,7 @@ public class TestProcessorResource extends JerseyTest {
|
|||
|
||||
assertNotNull(value);
|
||||
|
||||
try{
|
||||
assertTrue(value.get("name").asText().equals("mytransform"));
|
||||
} catch (Exception e){
|
||||
fail("Failed due to: " + e.toString());
|
||||
}
|
||||
|
||||
assertEquals("mytransform", value.get("name").asText());
|
||||
}
|
||||
|
||||
public static class MockRequestContext implements Factory<HttpServletRequest> {
|
||||
|
|
|
@ -18,12 +18,10 @@ package org.apache.nifi.web.standard.api.processor;
|
|||
|
||||
|
||||
import org.apache.nifi.web.ComponentDetails;
|
||||
import org.apache.nifi.web.HttpServletConfigurationRequestContext;
|
||||
import org.apache.nifi.web.HttpServletRequestContext;
|
||||
import org.apache.nifi.web.NiFiWebConfigurationContext;
|
||||
import org.apache.nifi.web.NiFiWebRequestContext;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.core.CacheControl;
|
||||
|
@ -32,8 +30,9 @@ import java.io.IOException;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
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;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -52,17 +51,6 @@ public class TestProcessorWebUtils {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Capability to get specific client revision has been removed as of commit 05a1d63090d97d06bf823821d1b0e9b5482c7cd2")
|
||||
// FIXME java11 Capability to get specific client revision has been removed as of commit 05a1d63090d97d06bf823821d1b0e9b5482c7cd2
|
||||
// Add test case for ProcessorWebUtils.getRequestContext() to verify proper revision is returned
|
||||
public void testGetComponentDetailsForProcessorWithSpecificClientRevision(){
|
||||
NiFiWebConfigurationContext configurationContext = mock(NiFiWebConfigurationContext.class);
|
||||
when(configurationContext.getComponentDetails(any(HttpServletConfigurationRequestContext.class))).thenReturn(new ComponentDetails.Builder().build());
|
||||
ComponentDetails componentDetails = ProcessorWebUtils.getComponentDetails(configurationContext,"1",mock(HttpServletRequest.class));
|
||||
assertNotNull(componentDetails);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyCacheControl(){
|
||||
Response.ResponseBuilder response = mock(Response.ResponseBuilder.class);
|
||||
|
@ -77,7 +65,7 @@ public class TestProcessorWebUtils {
|
|||
method.setAccessible(true);
|
||||
NiFiWebRequestContext requestContext = (NiFiWebRequestContext) method.invoke(null,"1",mock(HttpServletRequest.class));
|
||||
assertTrue(requestContext instanceof HttpServletRequestContext);
|
||||
assertTrue(requestContext.getId().equals("1"));
|
||||
assertEquals("1", requestContext.getId());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.nifi.web.standard.api.transformjson;
|
|||
|
||||
import com.bazaarvoice.jolt.Diffy;
|
||||
import com.bazaarvoice.jolt.JsonUtils;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.nifi.web.ComponentDetails;
|
||||
import org.apache.nifi.web.NiFiWebConfigurationContext;
|
||||
import org.apache.nifi.web.NiFiWebRequestContext;
|
||||
|
@ -31,9 +30,7 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory;
|
||||
import org.glassfish.jersey.test.spi.TestContainerFactory;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -44,18 +41,16 @@ import javax.ws.rs.core.Response.Status;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
||||
public class TestTransformJSONResource extends JerseyTest {
|
||||
|
||||
@Rule
|
||||
public final ExpectedException exception = ExpectedException.none();
|
||||
|
||||
public static final ServletContext servletContext = mock(ServletContext.class);
|
||||
|
||||
@Override
|
||||
|
@ -95,7 +90,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
assertNotNull(validate);
|
||||
assertTrue(!validate.isValid());
|
||||
assertFalse(validate.isValid());
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,7 +102,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.request()
|
||||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
TestCase.assertNotNull(validation);
|
||||
assertNotNull(validation);
|
||||
assertTrue(validation.isValid());
|
||||
}
|
||||
|
||||
|
@ -119,7 +114,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.request()
|
||||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
TestCase.assertNotNull(validation);
|
||||
assertNotNull(validation);
|
||||
assertTrue(validation.isValid());
|
||||
}
|
||||
|
||||
|
@ -131,7 +126,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.request()
|
||||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
TestCase.assertNotNull(validation);
|
||||
assertNotNull(validation);
|
||||
assertTrue(validation.isValid());
|
||||
}
|
||||
|
||||
|
@ -143,7 +138,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.request()
|
||||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
TestCase.assertNotNull(validation);
|
||||
assertNotNull(validation);
|
||||
assertTrue(!validation.isValid());
|
||||
}
|
||||
|
||||
|
@ -155,7 +150,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.request()
|
||||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
TestCase.assertNotNull(validation);
|
||||
assertNotNull(validation);
|
||||
assertTrue(validation.isValid());
|
||||
}
|
||||
|
||||
|
@ -198,7 +193,7 @@ public class TestTransformJSONResource extends JerseyTest {
|
|||
.post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
|
||||
|
||||
assertNotNull(validate);
|
||||
assertTrue(!validate.isValid());
|
||||
assertFalse(validate.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue