-
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
15 changed files
with
344 additions
and
85 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
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
20 changes: 20 additions & 0 deletions
20
...in/java/org/schoellerfamily/gedbrowser/controller/exception/DataSetNotFoundException.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,20 @@ | ||
package org.schoellerfamily.gedbrowser.controller.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Data set not found") | ||
public final class DataSetNotFoundException extends RuntimeException { | ||
/** */ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @param message the message to display | ||
*/ | ||
public DataSetNotFoundException(final String message) { | ||
super(message); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ain/java/org/schoellerfamily/gedbrowser/controller/exception/PersonNotFoundException.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,20 @@ | ||
package org.schoellerfamily.gedbrowser.controller.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Person not found") | ||
public final class PersonNotFoundException extends RuntimeException { | ||
/** */ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @param message the message to display | ||
*/ | ||
public PersonNotFoundException(final String message) { | ||
super(message); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ain/java/org/schoellerfamily/gedbrowser/controller/exception/SourceNotFoundException.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,20 @@ | ||
package org.schoellerfamily.gedbrowser.controller.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Source not found") | ||
public final class SourceNotFoundException extends RuntimeException { | ||
/** */ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @param message the message to display | ||
*/ | ||
public SourceNotFoundException(final String message) { | ||
super(message); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...owser/src/main/java/org/schoellerfamily/gedbrowser/controller/exception/package-info.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,5 @@ | ||
/** | ||
* Copyright 2017 Richard Schoeller | ||
* Exceptions for Spring Boot controllers for gedbrowser. | ||
*/ | ||
package org.schoellerfamily.gedbrowser.controller.exception; |
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
63 changes: 63 additions & 0 deletions
63
...er/src/test/java/org/schoellerfamily/gedbrowser/controller/test/LivingControllerTest.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,63 @@ | ||
package org.schoellerfamily.gedbrowser.controller.test; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.schoellerfamily.gedbrowser.Application; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.embedded.LocalServerPort; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest(classes = Application.class, | ||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@TestPropertySource(properties = {"management.port=0"}) | ||
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") | ||
public class LivingControllerTest { | ||
|
||
/** | ||
* Not sure what this is good for. | ||
*/ | ||
@Autowired | ||
private TestRestTemplate testRestTemplate; | ||
|
||
/** | ||
* Server port. | ||
*/ | ||
@LocalServerPort | ||
private int port; | ||
|
||
/** */ | ||
@Test | ||
public final void test1() { | ||
final String url = "http://localhost:" + port | ||
+ "/gedbrowser/living?db=gl120368"; | ||
final ResponseEntity<String> entity = | ||
testRestTemplate.getForEntity(url, String.class); | ||
|
||
then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
then(entity.getBody()).contains("<title>Living</title>"); | ||
} | ||
|
||
/** */ | ||
@Test | ||
public final void testBadDataSet() { | ||
final ResponseEntity<String> entity = | ||
testRestTemplate.getForEntity( | ||
"http://localhost:" + port | ||
+ "/gedbrowser/living?db=XYZZY", | ||
String.class); | ||
|
||
then(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); | ||
then(entity.getBody()).contains("Data set not found"); | ||
} | ||
} |
Oops, something went wrong.