Ankit | Refactor. Removes ManifestDataInvalid exception
This commit is contained in:
@@ -23,7 +23,7 @@ class ManifestController {
|
||||
|
||||
@PostMapping()
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
Object create(@Valid @RequestBody JsonNode jsonNode) throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
Object create(@Valid @RequestBody JsonNode jsonNode) throws IOException, ProcessingException {
|
||||
Manifest manifest = new Manifest(jsonNode);
|
||||
Object savedManifest = manifestService.add(manifest);
|
||||
return savedManifest;
|
||||
|
||||
@@ -19,13 +19,13 @@ public class ManifestService {
|
||||
this.manifestRepository = manifestRepository;
|
||||
}
|
||||
|
||||
Object add(Manifest manifest) throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
ProcessingReport processingReport = validationUtils.getReport(manifest.getData());
|
||||
if (processingReport.isSuccess()) {
|
||||
Object add(Manifest manifest) throws IOException, ProcessingException {
|
||||
// ProcessingReport processingReport = validationUtils.getReport(manifest.getData());
|
||||
// if (processingReport.isSuccess()) {
|
||||
Manifest savedManifest = manifestRepository.save(manifest);
|
||||
return savedManifest;
|
||||
}
|
||||
return processingReport.toString();
|
||||
// }
|
||||
// return processingReport.toString();
|
||||
}
|
||||
|
||||
Optional<Manifest> fetch(Long id) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ManifestControllerTest {
|
||||
String testData = "src/test/java/com/DeploymentPortal/api/Manifest/schema/TestData/";
|
||||
|
||||
@Test
|
||||
void expectToAddManifestFileUsingManifestResource() throws Exception, ManifestDataInvalid {
|
||||
void expectToAddManifestFileUsingManifestResource() throws Exception {
|
||||
mockMvc.perform(post(BASE_PATH + "/")
|
||||
.content("{\"version\":\"v1\",\"team\":{\"name\":\"accounting\"}}")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
@@ -42,7 +42,7 @@ public class ManifestControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void expectToReturnManifestDataWhenValidManifestDataAppearInPostCall() throws Exception, ManifestDataInvalid {
|
||||
void expectToReturnManifestDataWhenValidManifestDataAppearInPostCall() throws Exception{
|
||||
File jsonFile = new File(testData + "validManifestData.json");
|
||||
final JsonNode jsonNode = JsonLoader.fromFile(jsonFile);
|
||||
mockMvc.perform(post(BASE_PATH + "/")
|
||||
|
||||
@@ -21,7 +21,7 @@ class ManifestServiceTest {
|
||||
String testData = "src/test/java/com/DeploymentPortal/api/Manifest/schema/TestData/";
|
||||
|
||||
@Test
|
||||
void expectsToGetSavedInformationBackFromRepository() throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
void expectsToGetSavedInformationBackFromRepository() throws IOException, ProcessingException {
|
||||
String jsonData = "{\"version\":\"v1\",\"team\":{\"name\":\"accounting\"}}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(jsonData);
|
||||
@@ -31,7 +31,7 @@ class ManifestServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void expectToSaveManifestDataWhenValid() throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
void expectToSaveManifestDataWhenValid() throws IOException, ProcessingException {
|
||||
JsonNode jsonNode = getJsonNode();
|
||||
Manifest savedManifest = getManifest(jsonNode);
|
||||
|
||||
@@ -39,7 +39,7 @@ class ManifestServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void expectToGetSavedManifestDataById() throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
void expectToGetSavedManifestDataById() throws IOException, ProcessingException{
|
||||
JsonNode jsonNode = getJsonNode();
|
||||
Manifest savedManifest = getManifest(jsonNode);
|
||||
Long id = savedManifest.getId();
|
||||
@@ -51,7 +51,7 @@ class ManifestServiceTest {
|
||||
return JsonLoader.fromFile(new File(testData + "validManifestData.json"));
|
||||
}
|
||||
|
||||
private Manifest getManifest(JsonNode jsonNode) throws IOException, ProcessingException, ManifestDataInvalid {
|
||||
private Manifest getManifest(JsonNode jsonNode) throws IOException, ProcessingException{
|
||||
return (Manifest) manifestService.add(new Manifest(jsonNode));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user