Skip to content

Commit 91b0cb9

Browse files
DiegoKrupitzaschauder
authored andcommitted
Remove of useless throws ... in jUnit tests.
A lot of jUnit tests had in the method header a `throws` that is useless. For example `throws Exception` on a method where no exception is thrown. Removing this noice will make the tests more redable. Original pull request #2433
1 parent d0c3b1a commit 91b0cb9

27 files changed

+89
-91
lines changed

src/test/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessorUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ DefaultListableBeanFactory getBeanFactory() {
5959
}
6060

6161
@Test
62-
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() throws Exception {
62+
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() {
6363

6464
processor.postProcessBeanFactory(beanFactory);
6565

src/test/java/org/springframework/data/jpa/domain/support/AuditingNamespaceUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ String getConfigFile() {
3939
}
4040

4141
@Test
42-
void registersBeanDefinitions() throws Exception {
42+
void registersBeanDefinitions() {
4343

4444
BeanDefinition definition = beanFactory.getBeanDefinition(AuditingEntityListener.class.getName());
4545
PropertyValue propertyValue = definition.getPropertyValues().getPropertyValue("auditingHandler");

src/test/java/org/springframework/data/jpa/repository/EclipseLinkNamespaceUserRepositoryTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ void bindsNativeQueryResultsToProjectionByName() {}
106106
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
107107
*/
108108
@Override
109-
void findByEmptyArrayOfIntegers() throws Exception {}
109+
void findByEmptyArrayOfIntegers() {}
110110

111111
/**
112112
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
@@ -119,13 +119,13 @@ void findByAgeWithEmptyArrayOfIntegersOrFirstName() {
119119
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
120120
*/
121121
@Override
122-
void findByEmptyCollectionOfIntegers() throws Exception {}
122+
void findByEmptyCollectionOfIntegers() {}
123123

124124
/**
125125
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
126126
*/
127127
@Override
128-
void findByEmptyCollectionOfStrings() throws Exception {}
128+
void findByEmptyCollectionOfStrings() {}
129129

130130
/**
131131
* Ignores the test for EclipseLink.

src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests {
2929

3030
@Disabled
3131
@Override
32-
void executesNotInQueryCorrectly() throws Exception {}
32+
void executesNotInQueryCorrectly() {}
3333

3434
@Disabled
3535
@Override

src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,10 +40,9 @@ public class ORMInfrastructureTests {
4040
/**
4141
* Tests, that the context got initialized and injected correctly.
4242
*
43-
* @throws Exception
4443
*/
4544
@Test
46-
void contextInitialized() throws Exception {
45+
void contextInitialized() {
4746

4847
assertThat(context).isNotNull();
4948
}

src/test/java/org/springframework/data/jpa/repository/OpenJpaParentRepositoryIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,5 +23,5 @@ class OpenJpaParentRepositoryIntegrationTests extends ParentRepositoryIntegratio
2323

2424
@Override
2525
@Disabled
26-
void testWithJoin() throws Exception {}
26+
void testWithJoin() {}
2727
}

src/test/java/org/springframework/data/jpa/repository/OpenJpaUserRepositoryFinderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,5 +29,5 @@ class OpenJpaUserRepositoryFinderTests extends UserRepositoryFinderTests {
2929

3030
@Disabled
3131
@Override
32-
void findsByLastnameIgnoringCaseLike() throws Exception {}
32+
void findsByLastnameIgnoringCaseLike() {}
3333
}

src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, Criteria
8484
}
8585

8686
@Test // DATAJPA-287
87-
void testWithJoin() throws Exception {
87+
void testWithJoin() {
8888
Page<Parent> page = repository.findAll(new Specification<Parent>() {
8989
@Override
9090
public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, CriteriaBuilder cb) {

src/test/java/org/springframework/data/jpa/repository/RepositoryWithIdClassKeyTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class RepositoryWithIdClassKeyTests {
6161
* Specification 2.4.1.3 Derived Identities Example 2</a>
6262
*/
6363
@Test // DATAJPA-413
64-
void shouldSaveAndLoadEntitiesWithDerivedIdentities() throws Exception {
64+
void shouldSaveAndLoadEntitiesWithDerivedIdentities() {
6565

6666
Site site = siteRepository.save(new Site());
6767
Item item = itemRepository.save(new Item(123, 456));

src/test/java/org/springframework/data/jpa/repository/RoleRepositoryIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,15 +45,15 @@ public class RoleRepositoryIntegrationTests {
4545
@Autowired RoleRepository repository;
4646

4747
@Test
48-
void createsRole() throws Exception {
48+
void createsRole() {
4949

5050
Role reference = new Role("ADMIN");
5151
Role result = repository.save(reference);
5252
assertThat(result).isEqualTo(reference);
5353
}
5454

5555
@Test
56-
void updatesRole() throws Exception {
56+
void updatesRole() {
5757

5858
Role reference = new Role("ADMIN");
5959
Role result = repository.save(reference);

0 commit comments

Comments
 (0)