mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:48 +00:00
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:
parent
fc442120ce
commit
ae1bb8228c
8 changed files with 16 additions and 11 deletions
|
@ -57,10 +57,6 @@ public class Vet extends Person {
|
||||||
return this.specialties;
|
return this.specialties;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
|
||||||
this.specialties = specialties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public List<Specialty> getSpecialties() {
|
public List<Specialty> getSpecialties() {
|
||||||
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
||||||
|
|
|
@ -58,7 +58,7 @@ class MySqlIntegrationTests {
|
||||||
private RestTemplateBuilder builder;
|
private RestTemplateBuilder builder;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFindAll() throws Exception {
|
void testFindAll() {
|
||||||
vets.findAll();
|
vets.findAll();
|
||||||
vets.findAll(); // served from cache
|
vets.findAll(); // served from cache
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class PetClinicIntegrationTests {
|
||||||
private RestTemplateBuilder builder;
|
private RestTemplateBuilder builder;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFindAll() throws Exception {
|
void testFindAll() {
|
||||||
vets.findAll();
|
vets.findAll();
|
||||||
vets.findAll(); // served from cache
|
vets.findAll(); // served from cache
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.samples.petclinic;
|
package org.springframework.samples.petclinic;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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 static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -114,7 +115,16 @@ public class PostgresIntegrationTests {
|
||||||
Arrays.sort(names);
|
Arrays.sort(names);
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
String resolved = environment.getProperty(name);
|
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)) {
|
if (resolved.equals(value)) {
|
||||||
log.info(name + "=" + resolved);
|
log.info(name + "=" + resolved);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class PetTypeFormatterTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldThrowParseException() throws ParseException {
|
void shouldThrowParseException() {
|
||||||
given(this.pets.findPetTypes()).willReturn(makePetTypes());
|
given(this.pets.findPetTypes()).willReturn(makePetTypes());
|
||||||
Assertions.assertThrows(ParseException.class, () -> {
|
Assertions.assertThrows(ParseException.class, () -> {
|
||||||
petTypeFormatter.parse("Fish", Locale.ENGLISH);
|
petTypeFormatter.parse("Fish", Locale.ENGLISH);
|
||||||
|
|
|
@ -205,8 +205,6 @@ class ClinicServiceTests {
|
||||||
owner6.addVisit(pet7.getId(), visit);
|
owner6.addVisit(pet7.getId(), visit);
|
||||||
this.owners.save(owner6);
|
this.owners.save(owner6);
|
||||||
|
|
||||||
owner6 = this.owners.findById(6);
|
|
||||||
|
|
||||||
assertThat(pet7.getVisits()) //
|
assertThat(pet7.getVisits()) //
|
||||||
.hasSize(found + 1) //
|
.hasSize(found + 1) //
|
||||||
.allMatch(value -> value.getId() != null);
|
.allMatch(value -> value.getId() != null);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
// luck ((plain(st) UNIT test)! :)
|
// luck ((plain(st) UNIT test)! :)
|
||||||
class CrashControllerTests {
|
class CrashControllerTests {
|
||||||
|
|
||||||
CrashController testee = new CrashController();
|
final CrashController testee = new CrashController();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTriggerException() {
|
void testTriggerException() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.samples.petclinic.vet;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.util.SerializationUtils;
|
import org.springframework.util.SerializationUtils;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue