Package org.axonframework.saga

Examples of org.axonframework.saga.AssociationValue


    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


    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

    @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());
        assertNotNull(entityManager.find(SagaEntry.class, identifier));
    }
View Full Code Here

    @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());
        assertNotNull(entityManager.find(SagaEntry.class, identifier));
    }
View Full Code Here

    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

    private AssociationValue associationValue;

    @Before
    public void setUp() throws Exception {
        testSubject = new AssociationValuesImpl();
        associationValue = new AssociationValue("key", "value");
    }
View Full Code Here

    @Test
    public void testContains() {
        assertFalse(testSubject.contains(associationValue));
        testSubject.add(associationValue);
        assertTrue(testSubject.contains(associationValue));
        assertTrue(testSubject.contains(new AssociationValue("key", "value")));
        testSubject.remove(associationValue);
        assertFalse(testSubject.contains(associationValue));
    }
View Full Code Here

    }

    private void doProcessEvent(AsyncSagaProcessingEvent entry, long sequence, boolean endOfBatch)
            throws Exception {
        boolean sagaInvoked = invokeExistingSagas(entry);
        AssociationValue associationValue;
        switch (entry.getCreationHandler().getCreationPolicy()) {
            case ALWAYS:
                associationValue = entry.getInitialAssociationValue();
                if (associationValue != null && ownedByCurrentProcessor(entry.getNewSaga().getSagaIdentifier())) {
                    processNewSagaInstance(entry, associationValue);
View Full Code Here

        if (associationProperty == null) {
            return null;
        }

        Object associationValue = associationProperty.getValue(eventMessage.getPayload());
        return associationValue == null ? null : new AssociationValue(associationKey, associationValue.toString());
    }
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.