Examples of StubSaga


Examples of org.axonframework.saga.repository.StubSaga


    @DirtiesContext
    @Test
    public void testLoadSagaOfDifferentTypesWithSameAssociationValue_SagaFound() {
        StubSaga testSaga = new StubSaga("test1");
        MyOtherTestSaga otherTestSaga = new MyOtherTestSaga("test2");
        testSaga.registerAssociationValue(new AssociationValue("key", "value"));
        otherTestSaga.registerAssociationValue(new AssociationValue("key", "value"));
        repository.add(testSaga);
        repository.add(otherTestSaga);
        entityManager.flush();
        entityManager.clear();
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    }

    @DirtiesContext
    @Test
    public void testLoadSagaOfDifferentTypesWithSameAssociationValue_NoSagaFound() {
        StubSaga testSaga = new StubSaga("test1");
        MyOtherTestSaga otherTestSaga = new MyOtherTestSaga("test2");
        repository.add(testSaga);
        repository.add(otherTestSaga);
        testSaga.registerAssociationValue(new AssociationValue("key", "value"));
        otherTestSaga.registerAssociationValue(new AssociationValue("key", "value"));
        entityManager.flush();
        entityManager.clear();
        Set<String> actual = repository.find(InexistentSaga.class, new AssociationValue("key", "value"));
        assertTrue("Didn't expect any sagas", actual.isEmpty());
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    }

    @Test
    @DirtiesContext
    public void testLoadSagaOfDifferentTypesWithSameAssociationValue_SagaDeleted() {
        StubSaga testSaga = new StubSaga("test1");
        MyOtherTestSaga otherTestSaga = new MyOtherTestSaga("test2");
        repository.add(testSaga);
        repository.add(otherTestSaga);
        testSaga.registerAssociationValue(new AssociationValue("key", "value"));
        otherTestSaga.registerAssociationValue(new AssociationValue("key", "value"));
        testSaga.end();
        repository.commit(testSaga);
        entityManager.flush();
        entityManager.clear();
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertTrue("Didn't expect any sagas", actual.isEmpty());
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testAddAndLoadSaga_ByIdentifier() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        repository.add(saga);
        Saga loaded = repository.load(identifier);
        assertEquals(identifier, loaded.getSagaIdentifier());
        assertNotNull(entityManager.find(SagaEntry.class, identifier));
    }
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testAddAndLoadSaga_ByAssociationValue() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        saga.registerAssociationValue(new AssociationValue("key", "value"));
        repository.add(saga);
        Set<String> loaded = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(1, loaded.size());
        Saga loadedSaga = repository.load(loaded.iterator().next());
        assertEquals(identifier, loadedSaga.getSagaIdentifier());
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @Test
    @DirtiesContext
    public void testAddAndLoadSaga_AssociateValueAfterStorage() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        repository.add(saga);
        saga.registerAssociationValue(new AssociationValue("key", "value"));
        repository.commit(saga);
        Set<String> loaded = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(1, loaded.size());
        Saga loadedSaga = repository.load(loaded.iterator().next());
        assertEquals(identifier, loadedSaga.getSagaIdentifier());
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testLoadUncachedSaga_ByIdentifier() {
        repository.setSerializer(new XStreamSerializer());
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        entityManager.persist(new SagaEntry(saga, new XStreamSerializer()));
        entityManager.flush();
        entityManager.clear();
        Saga loaded = repository.load(identifier);
        assertNotSame(saga, loaded);
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testLoadUncachedSaga_ByAssociationValue() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        entityManager.persist(new SagaEntry(saga, serializer));
        entityManager.persist(new AssociationValueEntry(serializer.typeForClass(saga.getClass()).getName(),
                                                        identifier, new AssociationValue("key", "value")));
        entityManager.flush();
        entityManager.clear();
        Set<String> loaded = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(1, loaded.size());
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testLoadSaga_AssociationValueRemoved() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        saga.registerAssociationValue(new AssociationValue("key", "value"));
        entityManager.persist(new SagaEntry(saga, serializer));
        entityManager.persist(new AssociationValueEntry(serializer.typeForClass(saga.getClass()).getName(),
                                                        identifier, new AssociationValue("key", "value")));
        entityManager.flush();
        entityManager.clear();
        StubSaga loaded = (StubSaga) repository.load(identifier);
        loaded.removeAssociationValue("key", "value");
        repository.commit(loaded);
        Set<String> found = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(0, found.size());
    }
View Full Code Here

Examples of org.axonframework.saga.repository.StubSaga

    @DirtiesContext
    @Test
    public void testSaveSaga() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        entityManager.persist(new SagaEntry(saga, new XStreamSerializer()));
        entityManager.flush();
        StubSaga loaded = (StubSaga) repository.load(identifier);
        repository.commit(loaded);

        entityManager.clear();

        SagaEntry entry = entityManager.find(SagaEntry.class, identifier);
        StubSaga actualSaga = (StubSaga) entry.getSaga(new XStreamSerializer());
        assertNotSame(loaded, actualSaga);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.