-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,421 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Build | ||
|
||
on: [ push, pull_request, workflow_dispatch ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: "Maven Cache" | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
|
||
- name: "Setup Java" | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
|
||
- name: "Maven Test" | ||
run: mvn clean test cobertura:cobertura jacoco:report coveralls:report -DdryRun=true | ||
|
||
- name: "Coverage Report" | ||
uses: MikeEdgar/github-action@raw_coverage_file | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
path-to-file: './target/coveralls.json' | ||
coverage-format: raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[![Build Status](https://github.com/TAMULib/CatalogService/workflows/Build/badge.svg)](https://github.com/TAMULib/CatalogService/actions?query=workflow%3ABuild) | ||
[![Coverage Status](https://coveralls.io/repos/github/TAMULib/CatalogService/badge.svg)](https://coveralls.io/github/TAMULib/CatalogService) | ||
|
||
# CatalogService | ||
A service for interfacing with Library Catalogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/edu/tamu/app/controller/CatalogAccessControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package edu.tamu.app.controller; | ||
|
||
import static edu.tamu.weaver.response.ApiStatus.ERROR; | ||
import static edu.tamu.weaver.response.ApiStatus.SUCCESS; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import edu.tamu.app.model.CatalogHolding; | ||
import edu.tamu.app.service.CatalogServiceFactory; | ||
import edu.tamu.app.service.FolioCatalogService; | ||
import edu.tamu.weaver.response.ApiResponse; | ||
|
||
@RunWith(SpringRunner.class) | ||
public class CatalogAccessControllerTest { | ||
|
||
@Mock | ||
private CatalogServiceFactory catalogServiceFactory; | ||
|
||
@Mock | ||
private FolioCatalogService folioCatalogService; | ||
|
||
@InjectMocks | ||
private CatalogAccessController catalogAccessController; | ||
|
||
@Before | ||
public void setup() { | ||
when(catalogServiceFactory.getOrCreateCatalogService(any(String.class))).thenReturn(folioCatalogService); | ||
} | ||
|
||
@Test | ||
public void testGetHoldingsSuccess() { | ||
when(folioCatalogService.getHoldingsByBibId(any(String.class))).thenReturn(new ArrayList<CatalogHolding>()); | ||
|
||
ApiResponse response = catalogAccessController.getHoldings("evans", "foo"); | ||
assertEquals("Did not receive expected successful response", SUCCESS, response.getMeta().getStatus()); | ||
} | ||
|
||
@Test | ||
public void testGetHoldingsFailure() { | ||
when(folioCatalogService.getHoldingsByBibId(any(String.class))).thenReturn(null); | ||
|
||
ApiResponse response = catalogAccessController.getHoldings("evans", "foo"); | ||
assertEquals("Did not receive expected error response", ERROR, response.getMeta().getStatus()); | ||
} | ||
|
||
@Test | ||
public void testGetHoldingSuccess() { | ||
Map<String, Map<String, String>> catalogItems = new HashMap<>(); | ||
CatalogHolding holding = new CatalogHolding("marcRecordLeader", "mfhd", "issn", "isbn", "title", "author", "publisher", "place", "year", "genre", "edition", "fallBackLocationCode", "oclc", "recordId", "callNumber", catalogItems); | ||
|
||
when(folioCatalogService.getHolding(any(String.class), any(String.class))).thenReturn(holding); | ||
|
||
ApiResponse response = catalogAccessController.getHolding("evans", "foo", "bar"); | ||
assertEquals("Did not receive expected successful response", SUCCESS, response.getMeta().getStatus()); | ||
} | ||
|
||
@Test | ||
public void testGetHoldingFailure() { | ||
when(folioCatalogService.getHolding(any(String.class), any(String.class))).thenReturn(null); | ||
|
||
ApiResponse response = catalogAccessController.getHolding("evans", "foo", "bar"); | ||
assertEquals("Did not receive expected error response", ERROR, response.getMeta().getStatus()); | ||
} | ||
|
||
} |
24 changes: 0 additions & 24 deletions
24
src/test/java/edu/tamu/app/controller/CatalogAccessControllerTests.java
This file was deleted.
Oops, something went wrong.
112 changes: 0 additions & 112 deletions
112
src/test/java/edu/tamu/app/controller/MockCatalogService.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.