Examples of AssociationValue


Examples of org.axonframework.saga.AssociationValue

        assertTrue(testSubject.isEmpty());
        assertEquals("Wrong item count", 0, testSubject.size());
    }

    private AssociationValue av(String value) {
        return new AssociationValue("key", value);
    }
View Full Code Here

Examples of org.axonframework.saga.AssociationValue

    public void testFindAssociations() {
        List<AssociationValue> usedAssociations = new ArrayList<AssociationValue>(1000);
        for (int t = 0; t < 1000; t++) {
            String key = UUID.randomUUID().toString();
            for (int i = 0; i < 10; i++) {
                AssociationValue associationValue = new AssociationValue(key, UUID.randomUUID().toString());
                if (usedAssociations.size() < 1000) {
                    usedAssociations.add(associationValue);
                }
                testSubject.add(associationValue, "type", key);
            }
View Full Code Here

Examples of org.axonframework.saga.AssociationValue

        // to make sure this saga is found
        when(repository.find(any(Class.class), any(AssociationValue.class)))
                .thenReturn(new HashSet<String>(Arrays.asList(saga.getSagaIdentifier())));

        Set<String> found = testSubject.find(StubSaga.class, new AssociationValue("key", "value"));
        Iterator<String> iterator = found.iterator();

        final StubSaga saga2 = new StubSaga("id");
        saga2.associate("key", "value");
        testSubject.add(saga2);
View Full Code Here

Examples of org.axonframework.saga.AssociationValue

        saga.associate("key", "value");
        testSubject.add(saga);
        ehCache.removeAll();
        reset(sagaCache, associationsCache);

        final AssociationValue associationValue = new AssociationValue("key", "value");
        when(repository.find(StubSaga.class, associationValue)).thenReturn(Collections.singleton("id"));

        Set<String> actual = testSubject.find(StubSaga.class, associationValue);
        assertEquals(actual, singleton("id"));
        verify(associationsCache, atLeast(1)).get("org.axonframework.saga.repository.StubSaga/key=value");
View Full Code Here

Examples of org.axonframework.saga.AssociationValue

    @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

Examples of org.axonframework.saga.AssociationValue

    @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

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

Examples of org.axonframework.saga.AssociationValue

    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.AssociationValue

    @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

Examples of org.axonframework.saga.AssociationValue

    @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
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.