Minor code changes are the following:

-Removed unused variables from few files.
-Added null assertions in some tests.
-Removed unnecessary throw exceptions.
This commit is contained in:
Mousa Al Bateh 2024-10-03 20:06:42 +02:00 committed by Dave Syer
parent fc442120ce
commit ae1bb8228c
8 changed files with 16 additions and 11 deletions

View file

@ -57,10 +57,6 @@ public class Vet extends Person {
return this.specialties;
}
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
this.specialties = specialties;
}
@XmlElement
public List<Specialty> getSpecialties() {
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());

View file

@ -58,7 +58,7 @@ class MySqlIntegrationTests {
private RestTemplateBuilder builder;
@Test
void testFindAll() throws Exception {
void testFindAll() {
vets.findAll();
vets.findAll(); // served from cache
}

View file

@ -44,7 +44,7 @@ public class PetClinicIntegrationTests {
private RestTemplateBuilder builder;
@Test
void testFindAll() throws Exception {
void testFindAll() {
vets.findAll();
vets.findAll(); // served from cache
}

View file

@ -17,6 +17,7 @@
package org.springframework.samples.petclinic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Arrays;
@ -114,7 +115,16 @@ public class PostgresIntegrationTests {
Arrays.sort(names);
for (String name : names) {
String resolved = environment.getProperty(name);
String value = source.getProperty(name).toString();
assertNotNull(resolved, "resolved environment property: " + name + " is null.");
Object sourceProperty = source.getProperty(name);
assertNotNull(sourceProperty, "source property was expecting an object but is null.");
assertNotNull(sourceProperty.toString(), "source property toString() returned null.");
String value = sourceProperty.toString();
if (resolved.equals(value)) {
log.info(name + "=" + resolved);
}

View file

@ -68,7 +68,7 @@ class PetTypeFormatterTests {
}
@Test
void shouldThrowParseException() throws ParseException {
void shouldThrowParseException() {
given(this.pets.findPetTypes()).willReturn(makePetTypes());
Assertions.assertThrows(ParseException.class, () -> {
petTypeFormatter.parse("Fish", Locale.ENGLISH);

View file

@ -205,8 +205,6 @@ class ClinicServiceTests {
owner6.addVisit(pet7.getId(), visit);
this.owners.save(owner6);
owner6 = this.owners.findById(6);
assertThat(pet7.getVisits()) //
.hasSize(found + 1) //
.allMatch(value -> value.getId() != null);

View file

@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
// luck ((plain(st) UNIT test)! :)
class CrashControllerTests {
CrashController testee = new CrashController();
final CrashController testee = new CrashController();
@Test
void testTriggerException() {

View file

@ -18,6 +18,7 @@ package org.springframework.samples.petclinic.vet;
import org.junit.jupiter.api.Test;
import org.springframework.util.SerializationUtils;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.assertj.core.api.Assertions.assertThat;
/**