Skip to content
Open
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
60 changes: 60 additions & 0 deletions .github/workflows/covergae.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: 'petclinic-junit'

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
maven-version: '3.8.4'

- name: Download and prepare Keploy binary
run: |
curl --silent --location 'https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz' | tar xz -C /tmp
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin/keploybin

- name: Build and test with Maven and Keploy
run: |
cd spring-petclinic/spring-petclinic-rest
mvn clean install -Dmaven.test.skip=true
mvn test

- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
spring-petclinic/spring-petclinic-rest/target/site/e2e-ut-aggregate/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
title: Code Coverage
update-comment: true
pass-emoji: ':green_circle:'
ail-emoji: ':red_circle:'

- name: Get the Coverage info
run: |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"

- name: Fail PR if coverage of changed files is less than 60%
if: ${{ steps.jacoco.outputs.coverage-changed-files < 43.0 }}
run: |
echo "Coverage of changed files is less than 60%!"
exit 1


Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ public ResponseEntity<OwnerDto> addOwner(OwnerFieldsDto ownerFieldsDto) {
return new ResponseEntity<>(ownerDto, headers, HttpStatus.CREATED);
}

@PreAuthorize("hasRole(@roles.OWNER_ADMIN)")
@Override
public ResponseEntity<OwnerDto> addOwnernm(OwnerFieldsDto ownerFieldsDto) {
HttpHeaders headers = new HttpHeaders();
Owner owner = ownerMapper.toOwner(ownerFieldsDto);
this.clinicService.saveOwner(owner);
OwnerDto ownerDto = ownerMapper.toOwnerDto(owner);
headers.setLocation(UriComponentsBuilder.newInstance()
.path("/api/ownersnm/{id}").buildAndExpand(owner.getId()).toUri());
return new ResponseEntity<>(ownerDto, headers, HttpStatus.CREATED);
}

@PreAuthorize("hasRole(@roles.OWNER_ADMIN)")
@Override
public ResponseEntity<OwnerDto> updateOwner(Integer ownerId, OwnerFieldsDto ownerFieldsDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,16 @@ public void deleteOwner(Owner owner) throws DataAccessException {
@Transactional(readOnly = true)
public PetType findPetTypeById(int petTypeId) {
PetType petType = null;
petType = null;
try {
petType = petTypeRepository.findById(petTypeId);
} catch (ObjectRetrievalFailureException|EmptyResultDataAccessException e) {
// just ignore not found exceptions for Jdbc/Jpa realization
return null;
}
if (petType == null) {
return null;
}
return petType;
}

Expand Down