diff --git a/elide-async/src/main/java/com/yahoo/elide/async/service/AsyncExecutorService.java b/elide-async/src/main/java/com/yahoo/elide/async/service/AsyncExecutorService.java index a4a0f56f53..549c6898e6 100644 --- a/elide-async/src/main/java/com/yahoo/elide/async/service/AsyncExecutorService.java +++ b/elide-async/src/main/java/com/yahoo/elide/async/service/AsyncExecutorService.java @@ -85,6 +85,7 @@ public synchronized static AsyncExecutorService getInstance() { * Execute Query asynchronously. * @param queryObj Query Object * @param user User + * @param apiVersion api version */ public void executeQuery(AsyncQuery queryObj, User user, String apiVersion) { QueryRunner runner = runners.get(apiVersion); diff --git a/elide-async/src/test/java/com/yahoo/elide/async/service/AsyncQueryCleanerThreadTest.java b/elide-async/src/test/java/com/yahoo/elide/async/service/AsyncQueryCleanerThreadTest.java index a9e1b987c4..ad3189eeca 100644 --- a/elide-async/src/test/java/com/yahoo/elide/async/service/AsyncQueryCleanerThreadTest.java +++ b/elide-async/src/test/java/com/yahoo/elide/async/service/AsyncQueryCleanerThreadTest.java @@ -13,11 +13,20 @@ import static org.mockito.Mockito.verify; import com.yahoo.elide.Elide; +import com.yahoo.elide.ElideSettingsBuilder; +import com.yahoo.elide.async.models.AsyncQuery; import com.yahoo.elide.async.models.QueryStatus; +import com.yahoo.elide.core.EntityDictionary; +import com.yahoo.elide.core.datastore.inmemory.HashMapDataStore; +import com.yahoo.elide.security.checks.Check; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; + public class AsyncQueryCleanerThreadTest { private AsyncQueryCleanerThread cleanerThread; @@ -26,7 +35,15 @@ public class AsyncQueryCleanerThreadTest { @BeforeEach public void setupMocks() { - elide = mock(Elide.class); + HashMapDataStore inMemoryStore = new HashMapDataStore(AsyncQuery.class.getPackage()); + Map> checkMappings = new HashMap<>(); + + elide = new Elide( + new ElideSettingsBuilder(inMemoryStore) + .withEntityDictionary(new EntityDictionary(checkMappings)) + .withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")) + .build()); + asyncQueryDao = mock(DefaultAsyncQueryDAO.class); cleanerThread = new AsyncQueryCleanerThread(7, elide, 7, asyncQueryDao); } diff --git a/elide-contrib/elide-dynamic-config-helpers/pom.xml b/elide-contrib/elide-dynamic-config-helpers/pom.xml index dd1615d542..cddf889902 100644 --- a/elide-contrib/elide-dynamic-config-helpers/pom.xml +++ b/elide-contrib/elide-dynamic-config-helpers/pom.xml @@ -153,19 +153,11 @@ maven-checkstyle-plugin - maven-assembly-plugin - - - package - - single - - - + org.apache.maven.plugins + maven-compiler-plugin - - jar-with-dependencies - + 1.8 + 1.8 diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/config/ElideAsyncConfiguration.java b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/config/ElideAsyncConfiguration.java index 529d219709..664c9b3723 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/config/ElideAsyncConfiguration.java +++ b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/config/ElideAsyncConfiguration.java @@ -10,6 +10,8 @@ import static com.yahoo.elide.annotation.LifeCycleHookBinding.TransactionPhase.PRESECURITY; import com.yahoo.elide.Elide; +import com.yahoo.elide.ElideSettings; +import com.yahoo.elide.ElideSettingsBuilder; import com.yahoo.elide.async.hooks.ExecuteQueryHook; import com.yahoo.elide.async.hooks.UpdatePrincipalNameHook; import com.yahoo.elide.async.models.AsyncQuery; @@ -27,6 +29,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.TimeZone; + /** * Async Configuration For Elide Services. Override any of the beans (by defining your own) * and setting flags to disable in properties to change the default behavior. @@ -88,6 +92,13 @@ public AsyncCleanerService buildAsyncCleanerService(Elide elide, ElideConfigProp @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "elide.async", name = "defaultAsyncQueryDAO", matchIfMissing = true) public AsyncQueryDAO buildAsyncQueryDAO(Elide elide) { - return new DefaultAsyncQueryDAO(elide, elide.getDataStore()); + // Creating a new ElideSettings and Elide object for Async services + // which will have ISO8601 Dates. Used for DefaultAsyncQueryDAO. + ElideSettings asyncElideSettings = new ElideSettingsBuilder(elide.getDataStore()) + .withEntityDictionary(elide.getElideSettings().getDictionary()) + .withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")) + .build(); + Elide asyncElide = new Elide(asyncElideSettings); + return new DefaultAsyncQueryDAO(asyncElide, asyncElide.getDataStore()); } } diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/GraphqlController.java b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/GraphqlController.java index 8b0bd55625..9892a3492b 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/GraphqlController.java +++ b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/GraphqlController.java @@ -62,6 +62,7 @@ public GraphqlController(Elide elide) { /** * Single entry point for GraphQL requests. * + * @param requestHeaders request headers * @param graphQLDocument post data as json document * @param principal The user principal * @return response diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/SwaggerController.java b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/SwaggerController.java index 55cb67c35b..e6f41648a0 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/SwaggerController.java +++ b/elide-spring/elide-spring-boot-autoconfigure/src/main/java/com/yahoo/elide/spring/controllers/SwaggerController.java @@ -77,8 +77,10 @@ public SwaggerController(List docs) { public SwaggerController(Swagger doc) { log.debug("Started ~~"); documents = new HashMap<>(); + String apiVersion = doc.getInfo().getVersion(); + apiVersion = apiVersion == null ? NO_VERSION : apiVersion; - documents.put(Pair.of(NO_VERSION, ""), SwaggerBuilder.getDocument(doc)); + documents.put(Pair.of(apiVersion, ""), SwaggerBuilder.getDocument(doc)); } @GetMapping(value = {"/", ""}, produces = JSON_CONTENT_TYPE) @@ -111,6 +113,7 @@ public ResponseEntity call() throws Exception { /** * Read handler. * + * @param requestHeaders request headers * @param name document name * @return response The Swagger JSON document */ diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/models/jpa/v2/package-info.java b/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/models/jpa/v2/package-info.java index ed9eaa2bdb..bb06bbfd19 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/models/jpa/v2/package-info.java +++ b/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/models/jpa/v2/package-info.java @@ -3,6 +3,9 @@ * Licensed under the Apache License, Version 2.0 * See LICENSE file in project root for terms. */ +/** + * Models Package V2. + */ @ApiVersion(version = "1.0") package example.models.jpa.v2; diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/tests/ControllerTest.java b/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/tests/ControllerTest.java index 7d0031e87f..cfca612c80 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/tests/ControllerTest.java +++ b/elide-spring/elide-spring-boot-autoconfigure/src/test/java/example/tests/ControllerTest.java @@ -363,7 +363,8 @@ public void swaggerDocumentTest() { .statusCode(HttpStatus.SC_OK) .body("tags.name", containsInAnyOrder("group", "functionArgument", "metric", "metricFunction", "dimension", "column", "table", "asyncQuery", "asyncQueryResult", - "timeDimensionGrain", "timeDimension")); + "timeDimensionGrain", "timeDimension", "product", "playerCountry", "version", "playerStats", + "stats")); } @Test diff --git a/elide-spring/elide-spring-boot-autoconfigure/src/test/resources/application.yaml b/elide-spring/elide-spring-boot-autoconfigure/src/test/resources/application.yaml index 0403f64509..d5e9bde87b 100644 --- a/elide-spring/elide-spring-boot-autoconfigure/src/test/resources/application.yaml +++ b/elide-spring/elide-spring-boot-autoconfigure/src/test/resources/application.yaml @@ -12,7 +12,6 @@ elide: swagger: path: /doc enabled: true - version: "1.0" async: enabled: true threadPoolSize: 7 diff --git a/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java b/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java index 1b671d234d..3e9ab7c2a2 100644 --- a/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java +++ b/elide-standalone/src/main/java/com/yahoo/elide/standalone/config/ElideResourceConfig.java @@ -11,6 +11,7 @@ import com.yahoo.elide.Elide; import com.yahoo.elide.ElideSettings; +import com.yahoo.elide.ElideSettingsBuilder; import com.yahoo.elide.async.hooks.ExecuteQueryHook; import com.yahoo.elide.async.hooks.UpdatePrincipalNameHook; import com.yahoo.elide.async.models.AsyncQuery; @@ -39,6 +40,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.TimeZone; import java.util.function.Consumer; import javax.inject.Inject; import javax.persistence.EntityManagerFactory; @@ -113,9 +115,18 @@ protected void configure() { // Binding async service if (settings.enableAsync()) { + // Creating a new ElideSettings and Elide object for Async services + // which will have ISO8601 Dates. Used for DefaultAsyncQueryDAO. + ElideSettings asyncElideSettings = new ElideSettingsBuilder(elideSettings.getDataStore()) + .withEntityDictionary(elideSettings.getDictionary()) + .withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")) + .build(); + + Elide asyncElide = new Elide(asyncElideSettings); + AsyncQueryDAO asyncQueryDao = settings.getAsyncQueryDAO(); if (asyncQueryDao == null) { - asyncQueryDao = new DefaultAsyncQueryDAO(elide, elide.getDataStore()); + asyncQueryDao = new DefaultAsyncQueryDAO(asyncElide, asyncElide.getDataStore()); } bind(asyncQueryDao).to(AsyncQueryDAO.class);