petclinic-uncached
Changes
sonar-project.properties 13(+13 -0)
src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java 2(+1 -1)
Details
sonar-project.properties 13(+13 -0)
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100755
index 0000000..d84ed7c
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,13 @@
+# Required metadata
+sonar.projectKey=java-sonar-runner-simple
+sonar.projectName=Simple Java project analyzed with the SonarQube Runner
+sonar.projectVersion=1.0
+
+# Comma-separated paths to directories with sources (required)
+sonar.sources=src
+
+# Language
+sonar.language=java
+
+# Encoding of the source files
+sonar.sourceEncoding=UTF-8
\ No newline at end of file
diff --git a/src/main/java/org/springframework/samples/petclinic/model/PetType.java b/src/main/java/org/springframework/samples/petclinic/model/PetType.java
index 50cf039..99adf75 100644
--- a/src/main/java/org/springframework/samples/petclinic/model/PetType.java
+++ b/src/main/java/org/springframework/samples/petclinic/model/PetType.java
@@ -20,6 +20,7 @@ import javax.persistence.Table;
/**
* @author Juergen Hoeller
+ * Can be Cat, Dog, Hamster...
*/
@Entity
@Table(name = "types")
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java
index 05f6a24..604e8eb 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java
@@ -57,7 +57,7 @@ public class JdbcVetRepositoryImpl implements VetRepository {
/**
* Refresh the cache of Vets that the ClinicService is holding.
*
- * @see org.springframework.samples.petclinic.model.service.ClinicService#findVets()
+ * @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
*/
@Override
public Collection<Vet> findAll() throws DataAccessException {
diff --git a/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java b/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
index e72b5c1..9365821 100644
--- a/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
+++ b/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
@@ -26,7 +26,7 @@ import org.springframework.samples.petclinic.model.Visit;
/**
- * Mostly used as a facade for all Petclinic controllers
+ * Mostly used as a facade so all controllers have a single point of entry
*
* @author Michael Isvy
*/
diff --git a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java
index 9d1e882..0b8c7a7 100644
--- a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java
@@ -32,7 +32,7 @@ public class ValidatorTests {
}
@Test
- public void emptyFirstName() {
+ public void shouldNotValidateWhenFirstNameEmpty() {
LocaleContextHolder.setLocale(Locale.ENGLISH);
Person person = new Person();
diff --git a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
index 02a21ac..d9dc349 100644
--- a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
@@ -16,6 +16,7 @@
package org.springframework.samples.petclinic.service;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -59,8 +60,7 @@ public abstract class AbstractClinicServiceTests {
protected ClinicService clinicService;
@Test
- @Transactional
- public void findOwners() {
+ public void shouldFindOwners() {
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Davis");
assertEquals(2, owners.size());
owners = this.clinicService.findOwnerByLastName("Daviss");
@@ -68,18 +68,18 @@ public abstract class AbstractClinicServiceTests {
}
@Test
- public void findSingleOwner() {
+ public void shouldFindSingleOwner() {
Owner owner1 = this.clinicService.findOwnerById(1);
assertTrue(owner1.getLastName().startsWith("Franklin"));
+
Owner owner10 = this.clinicService.findOwnerById(10);
assertEquals("Carlos", owner10.getFirstName());
-
assertEquals(owner1.getPets().size(), 1);
}
@Test
@Transactional
- public void insertOwner() {
+ public void shouldInsertOwner() {
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
int found = owners.size();
Owner owner = new Owner();
@@ -89,24 +89,26 @@ public abstract class AbstractClinicServiceTests {
owner.setCity("Wollongong");
owner.setTelephone("4444444444");
this.clinicService.saveOwner(owner);
- Assert.assertNotEquals("Owner Id should have been generated", owner.getId().longValue(), 0);
+ assertNotEquals("Owner Id should have been generated", owner.getId().longValue(), 0);
+
owners = this.clinicService.findOwnerByLastName("Schultz");
assertEquals("Verifying number of owners after inserting a new one.", found + 1, owners.size());
}
@Test
@Transactional
- public void updateOwner() throws Exception {
+ public void shouldUpdateOwner() {
Owner o1 = this.clinicService.findOwnerById(1);
String old = o1.getLastName();
o1.setLastName(old + "X");
this.clinicService.saveOwner(o1);
o1 = this.clinicService.findOwnerById(1);
+
assertEquals(old + "X", o1.getLastName());
}
@Test
- public void findPet() {
+ public void shouldFindPetWithCorrectId() {
Collection<PetType> types = this.clinicService.findPetTypes();
Pet pet7 = this.clinicService.findPetById(7);
assertTrue(pet7.getName().startsWith("Samantha"));
@@ -119,7 +121,7 @@ public abstract class AbstractClinicServiceTests {
}
@Test
- public void getPetTypes() {
+ public void shouldFindAllPetTypes() {
Collection<PetType> petTypes = this.clinicService.findPetTypes();
PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
@@ -130,7 +132,7 @@ public abstract class AbstractClinicServiceTests {
@Test
@Transactional
- public void insertPet() {
+ public void shouldInsertPetIntoDatabaseAndGenerateId() {
Owner owner6 = this.clinicService.findOwnerById(6);
int found = owner6.getPets().size();
Pet pet = new Pet();
@@ -150,7 +152,7 @@ public abstract class AbstractClinicServiceTests {
@Test
@Transactional
- public void updatePet() throws Exception {
+ public void sholdUpdatePet() throws Exception {
Pet pet7 = this.clinicService.findPetById(7);
String old = pet7.getName();
pet7.setName(old + "X");
@@ -160,7 +162,7 @@ public abstract class AbstractClinicServiceTests {
}
@Test
- public void findVets() {
+ public void shouldFindVets() {
Collection<Vet> vets = this.clinicService.findVets();
Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
@@ -176,7 +178,7 @@ public abstract class AbstractClinicServiceTests {
@Test
@Transactional
- public void insertVisit() {
+ public void shouldAddNewVisitForPet() {
Pet pet7 = this.clinicService.findPetById(7);
int found = pet7.getVisits().size();
Visit visit = new Visit();
diff --git a/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java b/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java
index 295129f..fb29b0b 100644
--- a/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java
@@ -59,7 +59,7 @@ public class VisitsViewTests {
}
@Test
- public void getVisitsXml() throws Exception {
+ public void shouldFindVisitsInXmlFormat() throws Exception {
ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.TEXT_XML));
actions.andDo(print()); // action is logged into the console