-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in shibui-296 (pull request #26)
Mock implementation of entity ids search API * Mock implementation of entity ids search API * Clean up of schema generation -> move to a script Approved-by: Jonathan Johnson <jj@scaldingspoon.com>
- Loading branch information
Showing
8 changed files
with
128 additions
and
25 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
27 changes: 27 additions & 0 deletions
27
...ain/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntityIdsSearchController.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,27 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.controller; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.service.EntityIdsSearchService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/api/EntityIds/search") | ||
public class EntityIdsSearchController { | ||
|
||
EntityIdsSearchService entityIdsSearchService; | ||
|
||
public EntityIdsSearchController(EntityIdsSearchService entityIdsSearchService) { | ||
this.entityIdsSearchService = entityIdsSearchService; | ||
} | ||
|
||
@GetMapping | ||
ResponseEntity<?> search(@RequestParam String term, @RequestParam(required = false) Integer limit) { | ||
//Zero indicates no-limit | ||
final int resultLimit = (limit != null ? limit : 0); | ||
return ResponseEntity.ok(this.entityIdsSearchService.findBySearchTermAndOptionalLimit(term, resultLimit)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ternet2/tier/shibboleth/admin/ui/domain/frontend/EntityIdsSearchResultRepresentation.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,21 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.domain.frontend; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class EntityIdsSearchResultRepresentation implements Serializable { | ||
|
||
private static final long serialVersionUID = 8150816733364873026L; | ||
|
||
private List<String> entityIds = new ArrayList<>(); | ||
|
||
public EntityIdsSearchResultRepresentation(List<String> entityIds) { | ||
this.entityIds = entityIds; | ||
} | ||
|
||
public List<String> getEntityIds() { | ||
return Collections.unmodifiableList(entityIds); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/EntityIdsSearchService.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,23 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityIdsSearchResultRepresentation; | ||
import net.andreinc.mockneat.MockNeat; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* API component responsible for entity ids search. | ||
*/ | ||
@FunctionalInterface | ||
public interface EntityIdsSearchService { | ||
|
||
/** | ||
* Find a list of entity ids | ||
* @param searchTerm for the query | ||
* @param limit optional limit of query results to return. Zero or less value indicates no limit. | ||
* @return EntityIdsSearchResultRepresentation | ||
*/ | ||
EntityIdsSearchResultRepresentation findBySearchTermAndOptionalLimit(String searchTerm, int limit); | ||
} |
24 changes: 0 additions & 24 deletions
24
...rc/test/groovy/edu/internet2/tier/shibboleth/admin/ui/restapi/JsonSchemaGeneration.groovy
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
backend/src/test/resources/entity-ids-search-json-schema.json
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,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "Entity Ids Search Result Representation", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"entityIds": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
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,22 @@ | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.kjetland.jackson.jsonSchema.JsonSchemaGenerator | ||
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityDescriptorRepresentation | ||
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityIdsSearchResultRepresentation | ||
|
||
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT | ||
|
||
TARGET_DIRECTORY = "../resources" | ||
|
||
def generateSchemaFor(Class clazz, String outputFileName) { | ||
def om = new ObjectMapper().with { it.enable(INDENT_OUTPUT); it } | ||
def schemaGenerator = new JsonSchemaGenerator(om) | ||
def jsonSchema = schemaGenerator.generateJsonSchema(clazz) | ||
|
||
def jsonSchemaOutputFile = new File("$TARGET_DIRECTORY/$outputFileName") | ||
jsonSchemaOutputFile.delete() | ||
jsonSchemaOutputFile.withWriter('UTF-8') { | ||
it.write(jsonSchema.toString()) | ||
} | ||
} | ||
|
||
generateSchemaFor(EntityIdsSearchResultRepresentation, "entity-ids-search-json-schema.json") |