Package com.datastax.driver.core.querybuilder.Update

Examples of com.datastax.driver.core.querybuilder.Update.Where


    }

    @Test
    public void should_push_list_set_at_index_update() throws Exception {
        // Given
        final Where where = update("test").where();
        Object[] boundValues = new Object[] { "whatever" };
        Pair<Where, Object[]> pair = Pair.create(where, boundValues);

        final Optional<CASResultListener> casResultListener = Optional.absent();

        when(changeSet.getChangeType()).thenReturn(SET_TO_LIST_AT_INDEX);

        when(overrider.getWriteLevel(context)).thenReturn(EACH_QUORUM);
        when(statementGenerator.generateCollectionAndMapUpdateOperation(context, changeSet)).thenReturn(pair);
        when(context.getCASResultListener()).thenReturn(casResultListener);
        when(context.getSerialConsistencyLevel()).thenReturn(fromNullable(com.datastax.driver.core.ConsistencyLevel.LOCAL_SERIAL));

        // When
        daoContext.pushCollectionAndMapUpdateStatement(context, changeSet);

        // Then
        verify(context).pushStatement(statementWrapperCaptor.capture());
        final RegularStatementWrapper statementWrapper = statementWrapperCaptor.getValue();
        assertThat(statementWrapper.getValues()).contains(boundValues);
        assertThat(statementWrapper.getStatement().getConsistencyLevel()).isEqualTo(com.datastax.driver.core.ConsistencyLevel.EACH_QUORUM);
        assertThat(statementWrapper.getStatement().getSerialConsistencyLevel()).isEqualTo(com.datastax.driver.core.ConsistencyLevel.LOCAL_SERIAL);
        assertThat(where.getConsistencyLevel()).isEqualTo(com.datastax.driver.core.ConsistencyLevel.EACH_QUORUM);
    }
View Full Code Here


    }

    @Test
    public void should_push_list_remove_at_index_update() throws Exception {
        // Given
        final Where where = update("test").where();
        Object[] boundValues = new Object[] { "whatever" };
        Pair<Where, Object[]> pair = Pair.create(where, boundValues);

        final Optional<CASResultListener> casResultListener = Optional.absent();

        when(changeSet.getChangeType()).thenReturn(REMOVE_FROM_LIST_AT_INDEX);

        when(overrider.getWriteLevel(context)).thenReturn(EACH_QUORUM);
        when(statementGenerator.generateCollectionAndMapUpdateOperation(context, changeSet)).thenReturn(pair);
        when(context.getCASResultListener()).thenReturn(casResultListener);

        when(statementGenerator.generateCollectionAndMapUpdateOperation(context, changeSet)).thenReturn(pair);

        // When
        daoContext.pushCollectionAndMapUpdateStatement(context, changeSet);

        // Then
        verify(context).pushStatement(statementWrapperCaptor.capture());
        assertThat(statementWrapperCaptor.getValue().getValues()).contains(boundValues);

        assertThat(where.getConsistencyLevel()).isEqualTo(com.datastax.driver.core.ConsistencyLevel.EACH_QUORUM);
    }
View Full Code Here

        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, false);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table WHERE id=:id AND name=:name;");
    }
View Full Code Here

        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getPartitionComponents().getCQL3ComponentNames()).thenReturn(asList("id"));

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, true);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table WHERE id=:id;");
    }
View Full Code Here

        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(false);
        when(meta.getCQL3ColumnName()).thenReturn("id");

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, true);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table WHERE id=:id;");
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.querybuilder.Update.Where

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.