Skip to content

Remove of useless throws ... in jUnit tests. #2433

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

Closed
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -59,7 +59,7 @@ DefaultListableBeanFactory getBeanFactory() {
}

@Test
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() throws Exception {
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() {

processor.postProcessBeanFactory(beanFactory);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -39,7 +39,7 @@ String getConfigFile() {
}

@Test
void registersBeanDefinitions() throws Exception {
void registersBeanDefinitions() {

BeanDefinition definition = beanFactory.getBeanDefinition(AuditingEntityListener.class.getName());
PropertyValue propertyValue = definition.getPropertyValues().getPropertyValue("auditingHandler");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -106,7 +106,7 @@ void bindsNativeQueryResultsToProjectionByName() {}
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
*/
@Override
void findByEmptyArrayOfIntegers() throws Exception {}
void findByEmptyArrayOfIntegers() {}

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

/**
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
*/
@Override
void findByEmptyCollectionOfStrings() throws Exception {}
void findByEmptyCollectionOfStrings() {}

/**
* Ignores the test for EclipseLink.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2021 the original author or authors.
* Copyright 2011-2022 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 @@ -29,7 +29,7 @@ class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests {

@Disabled
@Override
void executesNotInQueryCorrectly() throws Exception {}
void executesNotInQueryCorrectly() {}

@Disabled
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -40,10 +40,9 @@ public class ORMInfrastructureTests {
/**
* Tests, that the context got initialized and injected correctly.
*
* @throws Exception
*/
@Test
void contextInitialized() throws Exception {
void contextInitialized() {

assertThat(context).isNotNull();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2022 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,5 +23,5 @@ class OpenJpaParentRepositoryIntegrationTests extends ParentRepositoryIntegratio

@Override
@Disabled
void testWithJoin() throws Exception {}
void testWithJoin() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2021 the original author or authors.
* Copyright 2011-2022 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 @@ -29,5 +29,5 @@ class OpenJpaUserRepositoryFinderTests extends UserRepositoryFinderTests {

@Disabled
@Override
void findsByLastnameIgnoringCaseLike() throws Exception {}
void findsByLastnameIgnoringCaseLike() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2022 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 @@ -84,7 +84,7 @@ public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, Criteria
}

@Test // DATAJPA-287
void testWithJoin() throws Exception {
void testWithJoin() {
Page<Parent> page = repository.findAll(new Specification<Parent>() {
@Override
public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2022 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 @@ -110,7 +110,7 @@ void shouldSupportSavingEntitiesWithCompositeKeyClassesWithEmbeddedIdsAndDerived
}

@Test // DATAJPA-472, DATAJPA-912
void shouldSupportFindAllWithPageableAndEntityWithIdClass() throws Exception {
void shouldSupportFindAllWithPageableAndEntityWithIdClass() {

IdClassExampleDepartment dep = new IdClassExampleDepartment();
dep.setName("TestDepartment");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 the original author or authors.
* Copyright 2016-2022 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 @@ -61,7 +61,7 @@ public class RepositoryWithIdClassKeyTests {
* Specification 2.4.1.3 Derived Identities Example 2</a>
*/
@Test // DATAJPA-413
void shouldSaveAndLoadEntitiesWithDerivedIdentities() throws Exception {
void shouldSaveAndLoadEntitiesWithDerivedIdentities() {

Site site = siteRepository.save(new Site());
Item item = itemRepository.save(new Item(123, 456));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2021 the original author or authors.
* Copyright 2011-2022 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 @@ -45,15 +45,15 @@ public class RoleRepositoryIntegrationTests {
@Autowired RoleRepository repository;

@Test
void createsRole() throws Exception {
void createsRole() {

Role reference = new Role("ADMIN");
Role result = repository.save(reference);
assertThat(result).isEqualTo(reference);
}

@Test
void updatesRole() throws Exception {
void updatesRole() {

Role reference = new Role("ADMIN");
Role result = repository.save(reference);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -144,7 +144,7 @@ void executesInKeywordForPageCorrectly() {
}

@Test
void executesNotInQueryCorrectly() throws Exception {
void executesNotInQueryCorrectly() {

List<User> result = userRepository.findByFirstnameNotIn(Arrays.asList("Dave", "Carter"));

Expand All @@ -160,7 +160,7 @@ void findsByLastnameIgnoringCase() {
}

@Test // DATAJPA-92
void findsByLastnameIgnoringCaseLike() throws Exception {
void findsByLastnameIgnoringCaseLike() {

List<User> result = userRepository.findByLastnameIgnoringCaseLike("BeAUfo%");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -33,7 +33,7 @@
class JpaRepositoryConfigDefinitionParserTests {

@Test
void getsTransactionManagerSet() throws Exception {
void getsTransactionManagerSet() {

DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2022 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 @@ -92,7 +92,7 @@ void doesNotRegisterProcessorIfAutoRegistered() {
}

@Test // DATAJPA-525
void guardsAgainstNullJavaTypesReturnedFromJpaMetamodel() throws Exception {
void guardsAgainstNullJavaTypesReturnedFromJpaMetamodel() {

ApplicationContext context = mock(ApplicationContext.class);
EntityManagerFactory emf = mock(EntityManagerFactory.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2021 the original author or authors.
* Copyright 2015-2022 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 @@ -33,7 +33,7 @@
class Jpa21UtilsUnitTests {

@Test // DATAJPA-696
void shouldBuildCorrectSubgraphForJpaEntityGraph() throws Exception {
void shouldBuildCorrectSubgraphForJpaEntityGraph() {

EntityGraph<?> entityGraph = mock(EntityGraph.class);
Subgraph<?> subgraph = mock(Subgraph.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -275,7 +275,7 @@ void returnsDefaultCountQueryNameBasedOnConfiguredNamedQueryName() throws Except
}

@Test // DATAJPA-185
void rejectsInvalidNamedParameter() throws Exception {
void rejectsInvalidNamedParameter() {

assertThatThrownBy(() -> getQueryMethod(InvalidRepository.class, "findByAnnotatedQuery", String.class))
.isInstanceOf(IllegalStateException.class)
Expand Down Expand Up @@ -344,8 +344,8 @@ void shouldFindEntityGraphAnnotationOnOverriddenSimpleJpaRepositoryMethodFindOne
doReturn(User.class).when(metadata).getDomainType();
doReturn(User.class).when(metadata).getReturnedDomainClass((Method) any());

JpaQueryMethod method = new JpaQueryMethod(JpaRepositoryOverride.class.getMethod("findOne", Integer.class), metadata,
factory, extractor);
JpaQueryMethod method = new JpaQueryMethod(JpaRepositoryOverride.class.getMethod("findOne", Integer.class),
metadata, factory, extractor);

assertThat(method.getEntityGraph()).isNotNull();
assertThat(method.getEntityGraph().getName()).isEqualTo("User.detail");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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 @@ -123,15 +123,15 @@ void bindWorksWithNullForPageable() throws Exception {
}

@Test
void usesIndexedParametersIfNoParamAnnotationPresent() throws Exception {
void usesIndexedParametersIfNoParamAnnotationPresent() {

Object[] values = { "foo" };
bind(useIndexedParameters, values);
verify(query).setParameter(eq(1), any());
}

@Test
void usesParameterNameIfAnnotated() throws Exception {
void usesParameterNameIfAnnotated() {

when(query.setParameter(eq("username"), any())).thenReturn(query);

Expand Down Expand Up @@ -185,8 +185,7 @@ void shouldSetTemporalQueryParameterToTimestamp() throws Exception {
}

@Test // DATAJPA-107
void shouldThrowIllegalArgumentExceptionIfIsAnnotatedWithTemporalParamAndParameterTypeIsNotDate()
throws Exception {
void shouldThrowIllegalArgumentExceptionIfIsAnnotatedWithTemporalParamAndParameterTypeIsNotDate() throws Exception {
Method method = SampleRepository.class.getMethod("invalidWithTemporalTypeParameter", String.class);

assertThatIllegalArgumentException().isThrownBy(() -> new JpaParameters(method));
Expand Down
Loading