Skip to content

Commit

Permalink
Source code cleanup by plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
harawata committed Nov 8, 2024
1 parent e9abfcd commit b45f64d
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/site/ko/xdoc/java-api.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
*/
package org.apache.ibatis.reflection.property;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

/**
* @author <a href="[email protected]">mawen12</a>
*
* @see PropertyTokenizer
*/
class PropertyTokenizerTest {
Expand All @@ -39,9 +40,8 @@ void shouldParsePropertySuccessfully() {
assertFalse(tokenizer.hasNext());
assertNull(tokenizer.getIndex());

assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
}

@Test
Expand All @@ -56,9 +56,8 @@ void shouldParsePropertyWhichContainsDelimSuccessfully() {

assertNull(tokenizer.getIndex());

assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
}

@Test
Expand All @@ -73,8 +72,7 @@ void shouldParsePropertyWhichContainsIndexSuccessfully() {
assertFalse(tokenizer.hasNext());
assertNull(tokenizer.getChildren());

assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@
*/
package org.apache.ibatis.reflection.wrapper;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.domain.blog.Author;
import org.apache.ibatis.domain.misc.RichType;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.reflection.property.PropertyTokenizer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author <a href="[email protected]">mawen12</a>
*
* @see BeanWrapper
*/
class BeanWrapperUnitTest extends ObjectWrapperBaseTest {
Expand Down Expand Up @@ -71,10 +72,12 @@ void shouldGetWhichContainsDelim() {
@Test
void shouldGetWhichContainsIndex() {
richType.setRichList(Arrays.asList(1L, "abc"));
richType.setRichMap(new HashMap<String, Object>(){{
put("key1", "value1");
put("key2", "value2");
}});
richType.setRichMap(new HashMap<String, Object>() {
{
put("key1", "value1");
put("key2", "value2");
}
});

assertEquals("abc", wrapper.get(new PropertyTokenizer("richList[1]")));
assertEquals("value2", wrapper.get(new PropertyTokenizer("richMap[key2]")));
Expand Down Expand Up @@ -199,15 +202,13 @@ void shouldInstantiatePropertyValue() {
@Test
@Override
void shouldAddElement() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.add("1"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.add("1"));
}

@Test
@Override
void shouldAddAll() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.addAll(new ArrayList<>()));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.addAll(new ArrayList<>()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package org.apache.ibatis.reflection.wrapper;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -28,12 +32,9 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

/**
* @author <a href="[email protected]">mawen12</a>
*
* @see CollectionWrapper
*/
@ExtendWith(MockitoExtension.class)
Expand All @@ -56,64 +57,55 @@ void setup() {
@Test
@Override
void shouldGet() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.get(tokenizer));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.get(tokenizer));
}

@Test
@Override
void shouldSet() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.set(tokenizer, null));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.set(tokenizer, null));
}

@Test
@Override
void shouldFindProperty() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.findProperty("abc", true));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.findProperty("abc", true));
}

@Test
@Override
void shouldGetGetterNames() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.getGetterNames());
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.getGetterNames());
}

@Test
@Override
void shouldGetSetterNames() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.getSetterNames());
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.getSetterNames());
}

@Test
@Override
void shouldGetGetterType() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.getGetterType("abc"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.getGetterType("abc"));
}

@Test
@Override
void shouldGetSetterType() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.getSetterType("abc"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.getSetterType("abc"));
}

@Test
@Override
void shouldHasGetter() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.hasGetter("abc"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.hasGetter("abc"));
}

@Test
@Override
void shouldHasSetter() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.hasSetter("abc"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.hasSetter("abc"));
}

@Test
Expand All @@ -126,7 +118,7 @@ void shouldIsCollection() {
@Override
void shouldInstantiatePropertyValue() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.instantiatePropertyValue("abc", tokenizer, null));
.isThrownBy(() -> wrapper.instantiatePropertyValue("abc", tokenizer, null));
}

@Test
Expand All @@ -140,11 +132,13 @@ void shouldAddElement() {
@Test
@Override
void shouldAddAll() {
List<Object> list = new ArrayList<>() {{
add("1");
add("2");
add("3");
}};
List<Object> list = new ArrayList<>() {
{
add("1");
add("2");
add("3");
}
};
wrapper.addAll(list);

verify(collection).addAll(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
*/
package org.apache.ibatis.reflection.wrapper;

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.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -30,12 +36,9 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mock;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

/**
* @author <a href="[email protected]">mawen12</a>
*
* @see MapWrapper
*/
class MapWrapperUnitTest extends ObjectWrapperBaseTest {
Expand Down Expand Up @@ -99,9 +102,11 @@ void shouldSet() {
void shouldSetWhichContainsDelim() {
wrapper.set(new PropertyTokenizer("author.id"), 1);

verify(map).put("author", new HashMap<>() {{
put("id", 1);
}});
verify(map).put("author", new HashMap<>() {
{
put("id", 1);
}
});
}

@Test
Expand All @@ -123,10 +128,12 @@ void shouldFindProperty() {
@Test
@Override
void shouldGetGetterNames() {
Set<String> sets = new HashSet<>() {{
add("key1");
add("key2");
}};
Set<String> sets = new HashSet<>() {
{
add("key1");
add("key2");
}
};
when(map.keySet()).thenReturn(sets);

String[] getterNames = wrapper.getGetterNames();
Expand All @@ -138,10 +145,12 @@ void shouldGetGetterNames() {
@Test
@Override
void shouldGetSetterNames() {
Set<String> sets = new HashSet<>() {{
add("key1");
add("key2");
}};
Set<String> sets = new HashSet<>() {
{
add("key1");
add("key2");
}
};
when(map.keySet()).thenReturn(sets);

String[] setterNames = wrapper.getSetterNames();
Expand Down Expand Up @@ -219,22 +228,21 @@ void shouldIsCollection() {
@Test
@Override
void shouldInstantiatePropertyValue() {
MetaObject result = wrapper.instantiatePropertyValue("abc", new PropertyTokenizer("key"), SystemMetaObject.DEFAULT_OBJECT_FACTORY);
MetaObject result = wrapper.instantiatePropertyValue("abc", new PropertyTokenizer("key"),
SystemMetaObject.DEFAULT_OBJECT_FACTORY);

assertFalse(result.hasGetter("key"));
}

@Test
@Override
void shouldAddElement() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.add("1"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.add("1"));
}

@Test
@Override
void shouldAddAll() {
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> wrapper.addAll(new ArrayList<>()));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> wrapper.addAll(new ArrayList<>()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/**
* @author <a href="[email protected]">mawen12</a>
*
* @see ObjectWrapper
*/
@ExtendWith(MockitoExtension.class)
Expand Down
Loading

0 comments on commit b45f64d

Please sign in to comment.