Search in sources :

Example 1 with StorageContext

use of com.codingchili.core.context.StorageContext in project chili-core by codingchili.

the class EntryWatcherTest method setUp.

@Before
public void setUp(TestContext test) {
    Async async = test.async();
    context = new StorageContext();
    createStorage(result -> {
        if (result.succeeded()) {
            this.storage = result.result();
            getQuery().poll(entry -> entry.forEach(item -> {
                storage.remove(item.getId(), removed -> {
                });
            }), () -> REMOVE_INTERVAL);
            storage.put(object, put -> {
                test.assertTrue(put.succeeded());
                async.complete();
            });
        } else {
            test.fail(result.cause());
        }
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) Timeout(io.vertx.ext.unit.junit.Timeout) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) StorageObject(com.codingchili.core.testing.StorageObject) Future(io.vertx.core.Future) TimeUnit(java.util.concurrent.TimeUnit) StorageContext(com.codingchili.core.context.StorageContext) Rule(org.junit.Rule) After(org.junit.After) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) Before(org.junit.Before) Async(io.vertx.ext.unit.Async) StorageContext(com.codingchili.core.context.StorageContext) Before(org.junit.Before)

Example 2 with StorageContext

use of com.codingchili.core.context.StorageContext in project chili-core by codingchili.

the class ContextMock method getRealmStore.

@Override
public void getRealmStore(Handler<AsyncResult<AsyncRealmStore>> handler) {
    new StorageLoader<RegisteredRealm>().privatemap(new StorageContext<>(this)).withValue(RegisteredRealm.class).withDB("", "").build(result -> {
        this.realms = new RealmDB(result.result());
        RegisteredRealm realm = new RegisteredRealm().setName("realmName").setAuthentication(new Token(new TokenFactory("s".getBytes()), "realmName"));
        realms.put(Future.future(), realm);
        handler.handle(Future.succeededFuture(realms));
    });
}
Also used : StorageLoader(com.codingchili.core.storage.StorageLoader) Token(com.codingchili.core.security.Token) TokenFactory(com.codingchili.core.security.TokenFactory) StorageContext(com.codingchili.core.context.StorageContext) RegisteredRealm(com.codingchili.realmregistry.configuration.RegisteredRealm) RealmDB(com.codingchili.realmregistry.model.RealmDB)

Aggregations

StorageContext (com.codingchili.core.context.StorageContext)2 Token (com.codingchili.core.security.Token)1 TokenFactory (com.codingchili.core.security.TokenFactory)1 StorageLoader (com.codingchili.core.storage.StorageLoader)1 StorageObject (com.codingchili.core.testing.StorageObject)1 RegisteredRealm (com.codingchili.realmregistry.configuration.RegisteredRealm)1 RealmDB (com.codingchili.realmregistry.model.RealmDB)1 AsyncResult (io.vertx.core.AsyncResult)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 Timeout (io.vertx.ext.unit.junit.Timeout)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 TimeUnit (java.util.concurrent.TimeUnit)1 After (org.junit.After)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1