-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elide Async Feature Unit and Integration Tests (#1311)
* Added integration,unit test setup for Async Module with few tests Co-authored-by: moizarafat <[email protected]> * Adding Licence headers, Sample entity and working Async test for POST,GET Co-authored-by: moizarafat <[email protected]> * Adding additional integration tests Co-authored-by: moizarafat <[email protected]> * Adding remaining integration tests and updating javadocs Co-authored-by: moizarafat <[email protected]> * Adding all unit tests Co-authored-by: moizarafat <[email protected]> * Updating tests to work with Singleton changes Co-authored-by: moizarafat <[email protected]> * Modifying tests to work with singleton logic Co-authored-by: moizarafat <[email protected]> * Resolving some codacy errors Co-authored-by: moizarafat <[email protected]> * Adding DSL for GraphQL and addressing review comments Co-authored-by: moizarafat <[email protected]> * Fixing unit tests and checkstyle errors Co-authored-by: moizarafat <[email protected]> * Moving tests to new format Co-authored-by: moizarafat <[email protected]> * Fixing session not closed error and checkstyle errors * Fixing imports Co-authored-by: moizarafat <[email protected]> * Removing unused method and updating harness Co-authored-by: moizarafat <[email protected]> * Updating unit tests Co-authored-by: moizarafat <[email protected]> * Updating ResourceConfig for AsyncTest Co-authored-by: moizarafat <[email protected]> * Moving logic for resource config to new test binder Co-authored-by: moizarafat <[email protected]> * Adding bindFactory logic for async services Co-authored-by: moizarafat <[email protected]> * Fixing IT * Fixing IT Co-authored-by: Abhino <[email protected]> * Adding Remaining integration tests Co-authored-by: moizarafat <[email protected]> * Consolidating filter logic for integration tests Co-authored-by: moizarafat <[email protected]> * Fixing legacy Hibernate entity manager store (so it doesn't recycle the entity manager * Adding additional integration tests for Standalone and Spring boot Co-authored-by: moizarafat <[email protected]> * Fixing codacy errors Co-authored-by: moizarafat <[email protected]> * Review Comments Co-authored-by: abhino <[email protected]> Co-authored-by: avijay <[email protected]> Co-authored-by: moizarafat <[email protected]> Co-authored-by: moiz arafat <[email protected]> Co-authored-by: Aaron Klish <[email protected]>
- Loading branch information
1 parent
a98f8f9
commit 39767cd
Showing
31 changed files
with
1,558 additions
and
100 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
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
35 changes: 35 additions & 0 deletions
35
elide-async/src/test/java/com/yahoo/elide/async/service/AsyncCleanerServiceTest.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,35 @@ | ||
/* | ||
* Copyright 2020, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package com.yahoo.elide.async.service; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import com.yahoo.elide.Elide; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class AsyncCleanerServiceTest { | ||
|
||
private AsyncCleanerService service; | ||
|
||
@BeforeAll | ||
public void setupMocks() { | ||
Elide elide = mock(Elide.class); | ||
|
||
AsyncQueryDAO dao = mock(DefaultAsyncQueryDAO.class); | ||
AsyncCleanerService.init(elide, 5, 60, dao); | ||
service = AsyncCleanerService.getInstance(); | ||
} | ||
|
||
@Test | ||
public void testCleanerSet() { | ||
assertNotNull(service); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
elide-async/src/test/java/com/yahoo/elide/async/service/AsyncExecutorServiceTest.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,74 @@ | ||
/* | ||
* Copyright 2020, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package com.yahoo.elide.async.service; | ||
|
||
import static com.yahoo.elide.core.EntityDictionary.NO_VERSION; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
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.User; | ||
import com.yahoo.elide.security.checks.Check; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class AsyncExecutorServiceTest { | ||
|
||
private AsyncExecutorService service; | ||
private Elide elide; | ||
private AsyncQueryDAO asyncQueryDao; | ||
|
||
@BeforeAll | ||
public void setupMocks() { | ||
HashMapDataStore inMemoryStore = new HashMapDataStore(AsyncQuery.class.getPackage()); | ||
Map<String, Class<? extends Check>> checkMappings = new HashMap<>(); | ||
|
||
elide = new Elide( | ||
new ElideSettingsBuilder(inMemoryStore) | ||
.withEntityDictionary(new EntityDictionary(checkMappings)) | ||
.build()); | ||
|
||
asyncQueryDao = mock(DefaultAsyncQueryDAO.class); | ||
|
||
AsyncExecutorService.init(elide, 5, 60, asyncQueryDao); | ||
|
||
service = AsyncExecutorService.getInstance(); | ||
} | ||
|
||
@Test | ||
public void testAsyncExecutorServiceSet() { | ||
assertEquals(elide, service.getElide()); | ||
assertNotNull(service.getRunners()); | ||
assertEquals(60, service.getMaxRunTime()); | ||
assertNotNull(service.getExecutor()); | ||
assertNotNull(service.getInterruptor()); | ||
assertEquals(asyncQueryDao, service.getAsyncQueryDao()); | ||
} | ||
|
||
@Test | ||
public void testExecuteQuery() { | ||
AsyncQuery queryObj = mock(AsyncQuery.class); | ||
User testUser = mock(User.class); | ||
|
||
service.executeQuery(queryObj, testUser, NO_VERSION); | ||
|
||
verify(asyncQueryDao, times(0)).updateStatus(queryObj, QueryStatus.QUEUED); | ||
} | ||
} |
Oops, something went wrong.