Package info.archinnov.achilles.exception

Examples of info.archinnov.achilles.exception.AchillesLightWeightTransactionException


    protected void notifyCASError(CASResult casResult) {
        if (casResultListener.isPresent()) {
            casResultListener.get().onCASError(casResult);
        } else {
            throw new AchillesLightWeightTransactionException(casResult);
        }
    }
View Full Code Here


        when(columnDefinitions.iterator().next()).thenReturn(col1, col2);

        when(invoker.invokeOnRowForType(row, DataType.cboolean().asJavaClass(), "[applied]")).thenReturn(false);
        when(invoker.invokeOnRowForType(row, DataType.bigint().asJavaClass(), "id")).thenReturn(10L);

        AchillesLightWeightTransactionException caughtEx = null;
        //When
        try {
            wrapper.checkForCASSuccess(resultSet);
        } catch (AchillesLightWeightTransactionException ace) {
            caughtEx = ace;
        }

        //Then
        assertThat(caughtEx).isNotNull();
        assertThat(caughtEx.operation()).isEqualTo(INSERT);
        assertThat(caughtEx.currentValues()).contains(MapEntry.entry("[applied]", false), MapEntry.entry("id", 10L));
    }
View Full Code Here

    @Test
    public void should_exception_when_trying_to_insert_with_cas_because_already_exist() throws Exception {
        //Given
        final EntityWithEnum entityWithEnum = new EntityWithEnum(10L, "name", EACH_QUORUM);
        Map<String, Object> expectedCurrentValues = ImmutableMap.<String, Object>of("id", 10L, "[applied]", false, "consistency_level", EACH_QUORUM.name(), "name", "name");
        AchillesLightWeightTransactionException casException = null;
        manager.insert(entityWithEnum);

        //When
        try {
            manager.insert(entityWithEnum, OptionsBuilder.ifNotExists());
        } catch (AchillesLightWeightTransactionException ace) {
            casException = ace;
        }

        assertThat(casException).isNotNull();
        assertThat(casException.operation()).isEqualTo(INSERT);
        assertThat(casException.currentValues()).isEqualTo(expectedCurrentValues);
        assertThat(casException.toString()).isEqualTo("CAS operation INSERT cannot be applied. Current values are: {[applied]=false, consistency_level=EACH_QUORUM, id=10, name=name}");
    }
View Full Code Here

    public void should_exception_when_failing_cas_update() throws Exception {
        //Given
        final EntityWithEnum entityWithEnum = new EntityWithEnum(10L, "John", EACH_QUORUM);
        final EntityWithEnum managed = manager.insert(entityWithEnum);
        Map<String, Object> expectedCurrentValues = ImmutableMap.<String, Object>of("[applied]", false, "consistency_level", EACH_QUORUM.name(), "name", "John");
        AchillesLightWeightTransactionException casException = null;
        managed.setName("Helen");

        //When
        try {
            manager.update(managed, ifConditions(new CASCondition("name", "name"), new CASCondition("consistency_level", EACH_QUORUM)));
        } catch (AchillesLightWeightTransactionException ace) {
            casException = ace;
        }

        assertThat(casException).isNotNull();
        assertThat(casException.operation()).isEqualTo(UPDATE);
        assertThat(casException.currentValues()).isEqualTo(expectedCurrentValues);
        assertThat(casException.toString()).isEqualTo("CAS operation UPDATE cannot be applied. Current values are: {[applied]=false, consistency_level=EACH_QUORUM, name=John}");
    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.exception.AchillesLightWeightTransactionException

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.