Skip to content

Commit

Permalink
:fix: importing org.junit.Assert and explicitly referencing its metho…
Browse files Browse the repository at this point in the history
…ds instead of having test classes extend it

Signed-off-by: dseurotech <davide.salvador@eurotech.com>
  • Loading branch information
dseurotech authored and Coduz committed Oct 28, 2022
1 parent c66568f commit 23d18ce
Show file tree
Hide file tree
Showing 72 changed files with 941 additions and 869 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;


@Category(JUnitTests.class)
public class KapuaSerializableBodyWriterTest extends Assert {
public class KapuaSerializableBodyWriterTest {

KapuaSerializableBodyWriter kapuaSerializableBodyWriter;
Annotation[] annotations;
Expand Down Expand Up @@ -65,57 +66,57 @@ public void write(int b) {

@Test
public void isWriteableTest() {
assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, annotations, mediaType));
Assert.assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, annotations, mediaType));
}

@Test
public void isWriteableNullTypeTest() {
assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(null, genericType, annotations, mediaType));
Assert.assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(null, genericType, annotations, mediaType));
}

@Test
public void isWriteableNullGenericTypeTest() {
assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, null, annotations, mediaType));
Assert.assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, null, annotations, mediaType));
}

@Test
public void isWriteableNullAnnotationsTest() {
assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, null, mediaType));
Assert.assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, null, mediaType));
}

@Test
public void isWriteableNullMediaTypeTest() {
assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, annotations, null));
Assert.assertTrue("True expected.", kapuaSerializableBodyWriter.isWriteable(String.class, genericType, annotations, null));
}

@Test
public void getSizeTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, annotations, mediaType));
}

@Test
public void getSizeNullKapuaSerializableTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(null, String.class, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(null, String.class, genericType, annotations, mediaType));
}

@Test
public void getSizeNullTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, null, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, null, genericType, annotations, mediaType));
}

@Test
public void getSizeNullGenericTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, null, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, null, annotations, mediaType));
}

@Test
public void getSizeNullAnnotationsTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, null, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, null, mediaType));
}

@Test
public void getSizeNullMediaTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, annotations, null));
Assert.assertEquals("Expected and actual values should be the same.", 0, kapuaSerializableBodyWriter.getSize(kapuaSerializable, String.class, genericType, annotations, null));
}

@Test(expected = WebApplicationException.class)
Expand Down Expand Up @@ -146,7 +147,7 @@ public void writeToTest() throws Exception {
try {
kapuaSerializableBodyWriter.writeTo(kapuaSerializable, String.class, genericType, annotations, mediaType, httpHeaders, outputStream);
} catch (Exception e) {
fail("Exception not expected.");
Assert.fail("Exception not expected.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
import java.util.LinkedList;
import java.util.List;


@Category(JUnitTests.class)
public class ListBodyWriterTest extends Assert {
public class ListBodyWriterTest {

ListBodyWriter listBodyWriter;
Type genericType;
Expand Down Expand Up @@ -66,57 +67,57 @@ public void write(int b) {

@Test
public void isWriteableTest() {
assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, annotations, mediaType));
Assert.assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, annotations, mediaType));
}

@Test
public void isWriteableNullTypeTest() {
assertTrue("True expected.", listBodyWriter.isWriteable(null, genericType, annotations, mediaType));
Assert.assertTrue("True expected.", listBodyWriter.isWriteable(null, genericType, annotations, mediaType));
}

@Test
public void isWriteableNullGenericTypeTest() {
assertTrue("True expected.", listBodyWriter.isWriteable(String.class, null, annotations, mediaType));
Assert.assertTrue("True expected.", listBodyWriter.isWriteable(String.class, null, annotations, mediaType));
}

@Test
public void isWriteableNullAnnotationsTest() {
assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, null, mediaType));
Assert.assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, null, mediaType));
}

@Test
public void isWriteableNullMediaTypeTest() {
assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, annotations, null));
Assert.assertTrue("True expected.", listBodyWriter.isWriteable(String.class, genericType, annotations, null));
}

@Test
public void getSizeTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, annotations, mediaType));
}

@Test
public void getSizeNullListTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(null, String.class, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(null, String.class, genericType, annotations, mediaType));
}

@Test
public void getSizeNullTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, null, genericType, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, null, genericType, annotations, mediaType));
}

@Test
public void getSizeNullGenericTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, null, annotations, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, null, annotations, mediaType));
}

@Test
public void getSizeNullAnnotationsTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, null, mediaType));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, null, mediaType));
}

@Test
public void getSizeNullMediaTypeTest() {
assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, annotations, null));
Assert.assertEquals("Expected and actual values should be the same.", 0, listBodyWriter.getSize(list, String.class, genericType, annotations, null));
}

@Test(expected = WebApplicationException.class)
Expand Down Expand Up @@ -147,7 +148,7 @@ public void writeToTest() throws Exception {
try {
listBodyWriter.writeTo(list, String.class, Mockito.mock(Type.class), annotations, mediaType, httpHeaders, outputStream);
} catch (Exception e) {
fail("Exception not expected.");
Assert.fail("Exception not expected.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;


@Category(JUnitTests.class)
public class MoxyJsonConfigContextResolverTest extends Assert {
public class MoxyJsonConfigContextResolverTest {

@Test
public void moxyJsonConfigContextResolverTest() {
Class[] classes = {null, String.class, Integer.class, Short.class, Long.class, Character.class, Double.class, Float.class, String.class};
MoxyJsonConfigContextResolver moxyJsonConfigContextResolver = new MoxyJsonConfigContextResolver();

for (Class clazz : classes) {
assertTrue("True expected.", moxyJsonConfigContextResolver.getContext(clazz) instanceof MoxyJsonConfig);
assertEquals("Expected and actual values should be the same.", moxyJsonConfigContextResolver.config, moxyJsonConfigContextResolver.getContext(clazz));
assertEquals("Expected and actual values should be the same.", "{jaxb.formatted.output=false, eclipselink.json.namespace-separator=., eclipselink.json.include-root=false, eclipselink.json.wrapper-as-array-name=true, eclipselink.json.marshal-empty-collections=true}", moxyJsonConfigContextResolver.config.getMarshallerProperties().toString());
Assert.assertTrue("True expected.", moxyJsonConfigContextResolver.getContext(clazz) instanceof MoxyJsonConfig);
Assert.assertEquals("Expected and actual values should be the same.", moxyJsonConfigContextResolver.config, moxyJsonConfigContextResolver.getContext(clazz));
Assert.assertEquals("Expected and actual values should be the same.", "{jaxb.formatted.output=false, eclipselink.json.namespace-separator=., eclipselink.json.include-root=false, eclipselink.json.wrapper-as-array-name=true, eclipselink.json.marshal-empty-collections=true}", moxyJsonConfigContextResolver.config.getMarshallerProperties().toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Category(JUnitTests.class)
public class KapuaTokenAuthenticationFilterTest extends Assert {
public class KapuaTokenAuthenticationFilterTest {

HttpServletRequest request;
HttpServletResponse response;
Expand All @@ -42,22 +43,22 @@ public void initialize() {
public void isAccessAllowedTrueTest() {
Mockito.when(request.getMethod()).thenReturn("OPTIONS");
for (Object mappedValue : mappedValues) {
assertTrue("True expected.", kapuaTokenAuthenticationFilter.isAccessAllowed(request, response, mappedValue));
Assert.assertTrue("True expected.", kapuaTokenAuthenticationFilter.isAccessAllowed(request, response, mappedValue));
}
}

@Test
public void onAccessDeniedTest() throws Exception {
assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(request, response));
Assert.assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(request, response));
}

@Test
public void onAccessDeniedNullRequestTest() throws Exception {
assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(null, response));
Assert.assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(null, response));
}

@Test(expected = NullPointerException.class)
public void onAccessDeniedNullResponseTest() throws Exception {
assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(request, null));
Assert.assertTrue("True expected.", kapuaTokenAuthenticationFilter.onAccessDenied(request, null));
}
}

0 comments on commit 23d18ce

Please sign in to comment.