Skip to content

Commit

Permalink
Merge pull request #51 from TheJacksonLaboratory/hotfix/tests
Browse files Browse the repository at this point in the history
property collision with environment variables, renaming to be more sp…
  • Loading branch information
iimpulse committed Apr 2, 2024
2 parents 15eedc2 + 3da3152 commit bff325e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ontology-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:
GCLOUD_REGISTRY_PROJECT_ID: ${{ secrets.GCLOUD_REGISTRY_PROJECT_ID }}
GCLOUD_REGISTRY_IMAGE_ENV: docker
GCLOUD_REGISTRY_IMAGE_PROJECT: ontology
ONTOLOGY: ${{ inputs.ontology }}
ONTOLOGY_SERVICE_ONTOLOGY: ${{ inputs.ontology }}
ONTOLOGY_SERVICE_LOAD: ${{ inputs.load }}
ONTOLOGY_SERVICE_INTERNATIONAL: ${{ inputs.international }}
SERVICE_NAME: ontology-service-${{ inputs.ontology }}
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
echo "PROJECT_VERSION=$(./gradlew properties -q | awk '/^version:/ {print $2}')" >> $GITHUB_ENV
- name: Get ontology data
run: |
bash ontology.sh ${ONTOLOGY}
bash ontology.sh ${ONTOLOGY_SERVICE_ONTOLOGY}
- name: Docker Login
run: |
gcloud auth configure-docker "${GCLOUD_GCR}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ontology-sanity.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Sanity Check Application
on: pull_request
env:
ONTOLOGY: hp
ONTOLOGY_SERVICE_ONTOLOGY: hp
ONTOLOGY_SERVICE_LOAD: true
jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jacksonlaboratory/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
info = @Info(
title = "ontology-service-${ontology}",
description = "A restful service for the ${ontology} ontology.",
version = "0.5.9",
version = "0.5.10",
contact = @Contact(name = "Michael Gargano", email = "[email protected]")
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public DataInitializer(TermRepository termRepository,
@Transactional
public void init() {
if(shouldLoad){
log.info("Loading ontology terms..");
log.info(String.format("Loading %s ontology terms..", graphService.ontologyName));
try {
this.termRepository.configure();
List<OntologyTerm> terms = graphService.getOntology().getTerms().stream().distinct().map(term ->
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jacksonlaboratory/service/GraphService.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* Stores a {@link MinimalOntology} and provides associated methods for traversal
*/
@Singleton
@Requires(property = "ontology")
@Transactional
public class GraphService {

Expand All @@ -41,8 +40,8 @@ public class GraphService {

private OntologyDataResolver dataResolver;

@Property(name = "ontology") String ontologyName;
@Property(name = "workingdir") String directory;
@Value("${ontology}") String ontologyName;
@Value("${workingdir}") String directory;

@Value("${international}")
boolean international;
Expand Down Expand Up @@ -101,7 +100,7 @@ public OntologyDataResolver getDataResolver() {

@PostConstruct
public void initialize() {
log.info("Loading ontology json..");
log.info(String.format("Loading %s ontology json..", ontologyName));
this.dataResolver = OntologyDataResolver.of(Path.of(directory), this.ontologyName);
File file = new File(dataResolver.ontologyJson().toUri());
this.ontology = MinimalOntologyLoader.loadOntology(file, ontologyName.toUpperCase());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ micronaut:
server:
port: 8086
application:
name: ontology-service-${ONTOLOGY:hp}
name: ontology-service-hp
router:
static-resources:
swagger:
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ micronaut:
cors:
enabled: true
application:
name: ontology-service-${ONTOLOGY:unknown}
name: ontology-service-${ONTOLOGY_SERVICE_ONTOLOGY:unknown}
router:
static-resources:
swagger:
Expand Down Expand Up @@ -47,7 +47,7 @@ jackson:

api-url:
prefix: /api
ontology: ${ONTOLOGY:unknown}
ontology: ${ONTOLOGY_SERVICE_ONTOLOGY:unknown}
load: ${ONTOLOGY_SERVICE_LOAD:true}
international: ${ONTOLOGY_SERVICE_INTERNATIONAL:false}
workingdir: "data"
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import java.nio.file.Path

class OntologyDataResolverSpec extends Specification {

void 'test of'(){
Path dataDirectory = Path.of("src/test/resources");
OntologyDataResolver dataResolver = HpoDataResolver.of(dataDirectory, "hp");
assertEquals(dataResolver.ontologyJson(), dataDirectory.resolve("hp-base.json"));
assertEquals(dataDirectory, dataResolver.dataDirectory());
void 'test of ontology data resolver'(){
given:
Path dataDirectory = Path.of("src/test/resources");
OntologyDataResolver dataResolver = OntologyDataResolver.of(dataDirectory, "hp");
expect:
dataResolver.ontologyJson() == dataDirectory.resolve("hp-base.json")
dataDirectory == dataResolver.dataDirectory()
}
}

0 comments on commit bff325e

Please sign in to comment.