Merge pull request #139 from spring-projects/junit-best-practices
Upgrade to spring-java-format 0.0.42
This commit is contained in:
@@ -167,7 +167,7 @@
|
||||
<dependency>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
<artifactId>spring-javaformat-checkstyle</artifactId>
|
||||
<version>0.0.35</version>
|
||||
<version>0.0.42</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class BeanPropertyItemReaderTest {
|
||||
class BeanPropertyItemReaderTests {
|
||||
|
||||
private MockExcelItemReader<Player> reader;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() {
|
||||
ExecutionContext executionContext = new ExecutionContext();
|
||||
|
||||
List<String[]> rows = new ArrayList<>();
|
||||
@@ -60,7 +60,7 @@ public class BeanPropertyItemReaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readandMapPlayers() throws Exception {
|
||||
void readandMapPlayers() throws Exception {
|
||||
Player p1 = this.reader.read();
|
||||
Player p2 = this.reader.read();
|
||||
Player p3 = this.reader.read();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-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.
|
||||
@@ -34,12 +34,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class BeanPropertyWithStaticHeaderItemReaderTest {
|
||||
class BeanPropertyWithStaticHeaderItemReaderTests {
|
||||
|
||||
private MockExcelItemReader<Player> reader;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() {
|
||||
ExecutionContext executionContext = new ExecutionContext();
|
||||
|
||||
List<String[]> rows = new ArrayList<>();
|
||||
@@ -64,7 +64,7 @@ public class BeanPropertyWithStaticHeaderItemReaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readandMapPlayers() throws Exception {
|
||||
void readAndMapPlayers() throws Exception {
|
||||
Player p1 = this.reader.read();
|
||||
Player p2 = this.reader.read();
|
||||
Player p3 = this.reader.read();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -37,10 +37,10 @@ import org.springframework.context.annotation.Scope;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class BeanWrapperRowMapperTest {
|
||||
class BeanWrapperRowMapperTests {
|
||||
|
||||
@Test
|
||||
public void givenNoNameWhenInitCompleteThenIllegalStateShouldOccur() {
|
||||
void givenNoNameWhenInitCompleteThenIllegalStateShouldOccur() {
|
||||
Assertions.assertThatThrownBy(() -> {
|
||||
BeanWrapperRowMapper<Player> mapper = new BeanWrapperRowMapper<>();
|
||||
mapper.afterPropertiesSet();
|
||||
@@ -48,7 +48,7 @@ public class BeanWrapperRowMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAValidRowWhenMappingThenAValidPlayerShouldBeConstructed() throws Exception {
|
||||
void givenAValidRowWhenMappingThenAValidPlayerShouldBeConstructed() throws Exception {
|
||||
BeanWrapperRowMapper<Player> mapper = new BeanWrapperRowMapper<>();
|
||||
mapper.setTargetType(Player.class);
|
||||
mapper.afterPropertiesSet();
|
||||
@@ -78,7 +78,7 @@ public class BeanWrapperRowMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAValidRowWhenMappingThenAValidPlayerShouldBeConstructedBasedOnPrototype() throws Exception {
|
||||
void givenAValidRowWhenMappingThenAValidPlayerShouldBeConstructedBasedOnPrototype() throws Exception {
|
||||
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(TestConfig.class);
|
||||
BeanWrapperRowMapper<Player> mapper = ctx.getBean("playerRowMapper", BeanWrapperRowMapper.class);
|
||||
@@ -27,10 +27,10 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class PoiItemReaderTypesTest {
|
||||
class PoiItemReaderTypesTests {
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToReadMultipleTypes() throws Exception {
|
||||
void shouldBeAbleToReadMultipleTypes() throws Exception {
|
||||
var reader = new PoiItemReader<String[]>();
|
||||
reader.setResource(new ClassPathResource("types.xls"));
|
||||
reader.setRowMapper(new PassThroughRowMapper());
|
||||
@@ -49,7 +49,7 @@ public class PoiItemReaderTypesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToReadMultipleTypesWithDatesAsIso() throws Exception {
|
||||
void shouldBeAbleToReadMultipleTypesWithDatesAsIso() throws Exception {
|
||||
var reader = new PoiItemReader<String[]>();
|
||||
reader.setResource(new ClassPathResource("types.xls"));
|
||||
reader.setRowMapper(new PassThroughRowMapper());
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -35,14 +35,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class PoiItemReaderWithBlankRowSheetTest {
|
||||
class PoiItemReaderWithBlankRowSheetTests {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private PoiItemReader<String[]> itemReader;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() {
|
||||
this.itemReader = new PoiItemReader<>();
|
||||
this.itemReader.setResource(new ClassPathResource("blankRow.xlsx"));
|
||||
this.itemReader.setLinesToSkip(1); // First line is column names
|
||||
@@ -55,7 +55,7 @@ public class PoiItemReaderWithBlankRowSheetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readExcelFileWithBlankRow() throws Exception {
|
||||
void readExcelFileWithBlankRow() throws Exception {
|
||||
assertThat(this.itemReader.getNumberOfSheets()).isEqualTo(1);
|
||||
String[] row;
|
||||
do {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -35,14 +35,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class PoiItemReaderWithErrorsTest {
|
||||
class PoiItemReaderWithErrorsTests {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private PoiItemReader<String[]> itemReader;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() {
|
||||
this.itemReader = new PoiItemReader<>();
|
||||
this.itemReader.setResource(new ClassPathResource("errors.xlsx"));
|
||||
this.itemReader.setLinesToSkip(1); // First line is column names
|
||||
@@ -55,7 +55,7 @@ public class PoiItemReaderWithErrorsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readExcelFileWithBlankRow() throws Exception {
|
||||
void readExcelFileWithBlankRow() throws Exception {
|
||||
assertThat(this.itemReader.getNumberOfSheets()).isEqualTo(1);
|
||||
String[] row;
|
||||
String[] lastRow = null;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-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.
|
||||
@@ -24,7 +24,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class StreamingXlsxItemReaderTest extends AbstractExcelItemReaderTests {
|
||||
class StreamingXlsxItemReaderTests extends AbstractExcelItemReaderTests {
|
||||
|
||||
@Override
|
||||
protected void configureItemReader(AbstractExcelItemReader<String[]> itemReader) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-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.
|
||||
@@ -24,7 +24,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class StreamingXlsxItemReaderWithBlankLinesTest extends AbstractExcelItemReaderTests {
|
||||
class StreamingXlsxItemReaderWithBlankLinesTests extends AbstractExcelItemReaderTests {
|
||||
|
||||
@Override
|
||||
protected void configureItemReader(AbstractExcelItemReader<String[]> itemReader) {
|
||||
@@ -26,10 +26,10 @@ import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class StreamingXlsxTypesTest {
|
||||
class StreamingXlsxTypesTests {
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToReadMultipleTypes() throws Exception {
|
||||
void shouldBeAbleToReadMultipleTypes() throws Exception {
|
||||
var reader = new StreamingXlsxItemReader<String[]>();
|
||||
reader.setResource(new ClassPathResource("types.xlsx"));
|
||||
reader.setRowMapper(new PassThroughRowMapper());
|
||||
@@ -47,7 +47,7 @@ public class StreamingXlsxTypesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToReadMultipleTypesWithDatesAsIso() throws Exception {
|
||||
void shouldBeAbleToReadMultipleTypesWithDatesAsIso() throws Exception {
|
||||
var reader = new StreamingXlsxItemReader<String[]>();
|
||||
reader.setResource(new ClassPathResource("types.xlsx"));
|
||||
reader.setRowMapper(new PassThroughRowMapper());
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class DefaultRowSetMetaDataTest {
|
||||
class DefaultRowSetMetaDataTests {
|
||||
|
||||
private static final String[] COLUMNS = { "col1", "col2", "col3" };
|
||||
|
||||
@@ -45,14 +45,14 @@ public class DefaultRowSetMetaDataTest {
|
||||
private ColumnNameExtractor columnNameExtractor;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.sheet = Mockito.mock(Sheet.class);
|
||||
this.columnNameExtractor = Mockito.mock(ColumnNameExtractor.class);
|
||||
this.rowSetMetaData = new DefaultRowSetMetaData(this.sheet, this.columnNameExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnColumnsFromColumnNameExtractor() {
|
||||
void shouldReturnColumnsFromColumnNameExtractor() {
|
||||
|
||||
given(this.columnNameExtractor.getColumnNames(this.sheet)).willReturn(COLUMNS);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DefaultRowSetMetaDataTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetAndReturnNameOfTheSheet() {
|
||||
void shouldGetAndReturnNameOfTheSheet() {
|
||||
|
||||
given(this.sheet.getName()).willReturn("testing123");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-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.
|
||||
@@ -24,12 +24,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marten Deinum
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class StaticColumnNameExtractorTest {
|
||||
class StaticColumnNameExtractorTests {
|
||||
|
||||
private static final String[] COLUMNS = { "col1", "col2", "col3", "foo", "bar" };
|
||||
|
||||
@Test
|
||||
public void shouldReturnSameHeadersAsPassedIn() {
|
||||
void shouldReturnSameHeadersAsPassedIn() {
|
||||
|
||||
StaticColumnNameExtractor columnNameExtractor = new StaticColumnNameExtractor(COLUMNS);
|
||||
String[] names = columnNameExtractor.getColumnNames(null);
|
||||
@@ -39,7 +39,7 @@ public class StaticColumnNameExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnACopyOfTheHeaders() {
|
||||
void shouldReturnACopyOfTheHeaders() {
|
||||
|
||||
StaticColumnNameExtractor columnNameExtractor = new StaticColumnNameExtractor(COLUMNS);
|
||||
String[] names = columnNameExtractor.getColumnNames(null);
|
||||
Reference in New Issue
Block a user