Package org.axonframework.saga

Examples of org.axonframework.saga.AssociationValue


    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());
        Saga loadedSaga = repository.load(loaded.iterator().next());
        assertEquals(identifier, loadedSaga.getSagaIdentifier());
        assertNotSame(loadedSaga, saga);
        assertNotNull(entityManager.find(SagaEntry.class, identifier));
View Full Code Here


    @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

    }

    @Test
    public void testAddingAnInactiveSagaDoesntStoreIt() {
        StubSaga testSaga = new StubSaga("test1");
        testSaga.registerAssociationValue(new AssociationValue("key", "value"));
        testSaga.end();

        repository.add(testSaga);
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(0, actual.size());
        Object actualSaga = repository.load("test1");
        assertNull(actualSaga);
    }
View Full Code Here

    @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);
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(1, actual.size());
        assertEquals("test1", actual.iterator().next());
    }
View Full Code Here

    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"));
        Set<String> actual = repository.find(InexistentSaga.class, new AssociationValue("key", "value"));
        assertTrue("Didn't expect any sagas", actual.isEmpty());
    }
View Full Code Here

    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);
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertTrue("Didn't expect any sagas", actual.isEmpty());
    }
View Full Code Here

    @Test
    public void testLoadSaga_AssociationValueRemoved() {
        String identifier = UUID.randomUUID().toString();
        StubSaga saga = new StubSaga(identifier);
        saga.registerAssociationValue(new AssociationValue("key", "value"));
        repository.storeSaga(saga);
        repository.storeAssociationValue(new AssociationValue("key", "value"),
                                         identifier, saga.getClass().getName());
        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

        assertEquals(void.class, manager.getTargetType());

    }

    private <T extends Saga> Set<T> repositoryContents(String lookupValue, Class<T> sagaType) {
        final Set<String> identifiers = sagaRepository.find(sagaType, new AssociationValue("myIdentifier",
                                                                                           lookupValue));
        Set<T> sagas = new HashSet<T>();
        for (String identifier : identifiers) {
            sagas.add((T) sagaRepository.load(identifier));
        }
View Full Code Here

    @DirtiesContext
    @Test
    public void testAddingAnInactiveSagaDoesntStoreIt() {
        StubSaga testSaga = new StubSaga("test1");
        testSaga.registerAssociationValue(new AssociationValue("key", "value"));
        testSaga.end();

        repository.add(testSaga);
        entityManager.flush();
        entityManager.clear();
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(0, actual.size());
        Object actualSaga = repository.load("test1");
        assertNull(actualSaga);
    }
View Full Code Here

    @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();
        Set<String> actual = repository.find(StubSaga.class, new AssociationValue("key", "value"));
        assertEquals(1, actual.size());
        assertEquals("test1", actual.iterator().next());
    }
View Full Code Here

TOP

Related Classes of org.axonframework.saga.AssociationValue

Copyright © 2018 www.massapicom. 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.