Skip to content

Further cleanup of tests #3344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/test/java/org/apache/ibatis/domain/blog/Author.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -121,8 +121,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result;
result = id;
int result = id;
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,7 +52,7 @@ public boolean equals(Object o) {

final ComplexImmutableAuthor that = (ComplexImmutableAuthor) o;

if ((bio != null ? !bio.equals(that.bio) : that.bio != null) || (favouriteSection != that.favouriteSection)
if ((bio != null ? !bio.equals(that.bio) : that.bio != null) || favouriteSection != that.favouriteSection
|| (theComplexImmutableAuthorId != null ? !theComplexImmutableAuthorId.equals(that.theComplexImmutableAuthorId)
: that.theComplexImmutableAuthorId != null)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,7 +55,7 @@ public boolean equals(Object o) {

final ComplexImmutableAuthorId that = (ComplexImmutableAuthorId) o;

if ((id != that.id) || (email != null ? !email.equals(that.email) : that.email != null)
if (id != that.id || (email != null ? !email.equals(that.email) : that.email != null)
|| (password != null ? !password.equals(that.password) : that.password != null)
|| (username != null ? !username.equals(that.username) : that.username != null)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,8 +88,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result;
result = id;
int result = id;
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/apache/ibatis/domain/blog/PostLite.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,7 +54,7 @@ public boolean equals(Object o) {

final PostLite that = (PostLite) o;

if ((blogId != that.blogId) || (theId != null ? !theId.equals(that.theId) : that.theId != null)) {
if (blogId != that.blogId || (theId != null ? !theId.equals(that.theId) : that.theId != null)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.apache.ibatis.executor.loader;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
package org.apache.ibatis.mapping;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
8 changes: 3 additions & 5 deletions src/test/java/org/apache/ibatis/reflection/ArrayUtilTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,8 +27,7 @@ class ArrayUtilTest {

@Test
void testHashCode() {
Object arr;
arr = new long[] { 1 };
Object arr = new long[] { 1 };
assertEquals(Arrays.hashCode((long[]) arr), ArrayUtil.hashCode(arr));
arr = new int[] { 1 };
assertEquals(Arrays.hashCode((int[]) arr), ArrayUtil.hashCode(arr));
Expand Down Expand Up @@ -84,8 +83,7 @@ void testequals() {

@Test
void testToString() {
Object arr;
arr = new long[] { 1 };
Object arr = new long[] { 1 };
assertEquals(Arrays.toString((long[]) arr), ArrayUtil.toString(arr));
arr = new int[] { 1 };
assertEquals(Arrays.toString((int[]) arr), ArrayUtil.toString(arr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
package org.apache.ibatis.reflection.property;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
package org.apache.ibatis.reflection.wrapper;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
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 java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
package org.apache.ibatis.reflection.wrapper;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
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 java.util.Arrays;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,7 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if ((obj == null) || (getClass() != obj.getClass())) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
EntityKey other = (EntityKey) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ private static List<Cursor<?>> getCursors(SqlSession sqlSession) throws NoSuchFi
DefaultSqlSession session = (DefaultSqlSession) sqlSession;
Field cursorListField = DefaultSqlSession.class.getDeclaredField("cursorList");
cursorListField.setAccessible(true);
List<Cursor<?>> cursorList = (List<Cursor<?>>) cursorListField.get(session);
return cursorList;
return (List<Cursor<?>>) cursorListField.get(session);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ void shouldNullItemNotStopIteration() {
// next() has not been called, index is still -1
Assertions.assertEquals(-1, cursor.getCurrentIndex());

User user;
user = iterator.next();
User user = iterator.next();
Assertions.assertNull(user);
Assertions.assertEquals(0, cursor.getCurrentIndex());

Expand Down Expand Up @@ -455,8 +454,7 @@ void shouldRowBoundsCountNullItem() {
Assertions.assertTrue(cursor.isOpen());
Assertions.assertFalse(cursor.isConsumed());

User user;
user = iterator.next();
User user = iterator.next();
Assertions.assertEquals("Kate", user.getName());
Assertions.assertEquals(1, cursor.getCurrentIndex());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class Contract {
private Owner owner;

public Contract(Integer id, Owner owner) {
super();
this.id = id;
this.owner = owner;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,11 +21,9 @@ public class Owner {
private Vehicle vehicle;

public Owner() {
super();
}

public Owner(Integer id, Vehicle vehicle) {
super();
this.id = id;
this.vehicle = vehicle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public String getMessage() {

private int value;

private Mood(int value) {
Mood(int value) {
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void shouldReturnProperPrimitiveType() {
}
List<Long> lcodes = ProductDAO.selectProductCodesL();
for (Object lcode : lcodes) {
assertFalse((lcode instanceof Integer));
assertFalse(lcode instanceof Integer);
}
List<BigDecimal> bcodes = ProductDAO.selectProductCodesB();
for (Object bcode : bcodes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@ public class User {
private Birthday dob;

public User(String id, String name) {
super();
this.id = Integer.valueOf(id);
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package org.apache.ibatis.transaction.jdbc;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package org.apache.ibatis.transaction.managed;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void setup() {
this.transaction = new ManagedTransaction(connection, true);
}

@Override
@Test
void shouldGetConnection() throws SQLException {
Connection result = transaction.getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down Expand Up @@ -50,6 +52,7 @@ void setup() {
this.transaction = new ManagedTransaction(dataSource, TransactionIsolationLevel.READ_COMMITTED, true);
}

@Override
@Test
void shouldGetConnection() throws SQLException {
when(dataSource.getConnection()).thenReturn(connection);
Expand Down
Loading