Skip to content
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6.0.1
- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v5.1.0
with:
java-version: 17
distribution: 'liberica'
cache: maven
- name: Build with Maven
run: ./mvnw -B package --file pom.xml
54 changes: 36 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<version>4.0.1</version>
</parent>
<name>petclinic</name>

Expand All @@ -22,10 +22,12 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- Web dependencies -->
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
<webjars-jquery.version>2.2.4</webjars-jquery.version>
<wro4j.version>1.8.0</wro4j.version>
<webjars-locator.version>1.1.2</webjars-locator.version>
<webjars-bootstrap.version>3.4.1</webjars-bootstrap.version>
<webjars-font-awesome.version>4.7.0</webjars-font-awesome.version>
<webjars-jquery-ui.version>1.13.2</webjars-jquery-ui.version>
<webjars-jquery.version>3.5.0</webjars-jquery.version>
<wro4j.version>2.1.1</wro4j.version>

<jacoco.version>0.8.2</jacoco.version>
</properties>
Expand All @@ -50,22 +52,12 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>

<!-- Databases -->
<dependency>
Expand All @@ -74,8 +66,8 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-flyway</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
Expand Down Expand Up @@ -111,6 +103,32 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-mysql</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
package org.springframework.samples.petclinic.owner;

import java.text.ParseException;
import java.util.Collection;
import java.util.Locale;
import java.util.stream.Collectors;

import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.springframework.samples.petclinic.vet;

import java.util.Collection;
import java.util.List;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/less/petclinic.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@icon-font-path: "../../webjars/bootstrap/3.3.6/fonts/";
@icon-font-path: "../../webjars/bootstrap/3.4.1/fonts/";

@spring-green: #6db33f;
@spring-dark-green: #5fa134;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/fragments/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
</div>
</div>

<script th:src="@{/webjars/jquery/2.2.4/jquery.min.js}"></script>
<script th:src="@{/webjars/jquery-ui/1.11.4/jquery-ui.min.js}"></script>
<script th:src="@{/webjars/bootstrap/3.3.6/js/bootstrap.min.js}"></script>
<script th:src="@{/webjars/jquery/3.5.0/jquery.min.js}"></script>
<script th:src="@{/webjars/jquery-ui/1.13.2/jquery-ui.min.js}"></script>
<script th:src="@{/webjars/bootstrap/3.4.1/js/bootstrap.min.js}"></script>

</body>

Expand Down
2 changes: 1 addition & 1 deletion src/main/wro/wro.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<groups xmlns="http://www.isdc.ro/wro">
<group name="petclinic">
<css>classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less</css>
<css>classpath:META-INF/resources/webjars/bootstrap/3.4.1/less/bootstrap.less</css>
<css>/petclinic.less</css>
</group>
</groups>
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;

import org.assertj.core.util.Lists;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.samples.petclinic.owner.Owner;
import org.springframework.samples.petclinic.owner.OwnerController;
import org.springframework.samples.petclinic.owner.OwnerRepository;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.samples.petclinic.visit.VisitRepository;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

/**
Expand All @@ -50,13 +46,13 @@ public class OwnerControllerTests {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private OwnerRepository owners;

@MockBean
@MockitoBean
private PetRepository pets;

@MockBean
@MockitoBean
private VisitRepository visits;

private Owner george;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

/**
Expand All @@ -44,10 +44,10 @@ public class PetControllerTests {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private PetRepository pets;

@MockBean
@MockitoBean
private OwnerRepository owners;

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.samples.petclinic.visit.VisitRepository;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

/**
Expand All @@ -43,13 +43,13 @@ public class VisitControllerTests {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private VisitRepository visits;

@MockBean
@MockitoBean
private PetRepository pets;

@MockBean
@MockitoBean
private OwnerRepository owners;

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
import org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.samples.petclinic.owner.*;
import org.springframework.samples.petclinic.vet.SpecialtyRef;
Expand All @@ -43,7 +43,7 @@
* execution.</li>
* <li><strong>Dependency Injection</strong> of test fixture instances, meaning that we don't need to perform
* application context lookups. See the use of {@link Autowired @Autowired} on the <code>{@link
* ClinicServiceTests#clinicService clinicService}</code> instance variable, which uses autowiring <em>by type</em>.
* ClinicServiceTests clinicService}</code> instance variable, which uses autowiring <em>by type</em>.
* <li><strong>Transaction management</strong>, meaning each test method is executed in its own transaction, which is
* automatically rolled back by default. Thus, even if tests insert or otherwise change database state, there is no need
* for a teardown or cleanup script.
Expand Down Expand Up @@ -191,10 +191,10 @@ public void shouldAddNewVisitForPet() {
}

@Test
public void shouldFindVisitsByPetId() throws Exception {
public void shouldFindVisitsByPetId() {
Collection<Visit> visits = this.visits.findByPetId(7);
assertThat(visits.size()).isEqualTo(2);
Visit[] visitArr = visits.toArray(new Visit[visits.size()]);
Visit[] visitArr = visits.toArray(new Visit[0]);
assertThat(visitArr[0].getDate()).isNotNull();
assertThat(visitArr[0].getPetId()).isEqualTo(7);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.test.web.servlet.MockMvc;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

/**
* Test class for the {@link VetController}
Expand All @@ -42,10 +41,10 @@ public class VetControllerTests {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private VetRepository vets;

@MockBean
@MockitoBean
private SpecialtyRepository specialties;

@BeforeEach
Expand Down