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

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


        //Given
        final Conditions conditions = update("table").onlyIf();
        when(meta.getCQL3ColumnName()).thenReturn("names");

        //When
        final Assignments actual = view.generateUpdateForRemovedAtIndexElement(conditions, 2);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table SET names[2]=null;");
    }
View Full Code Here


    @Test
    public void should_prepare_update_fields_ps() throws Exception {
        PropertyMeta nameMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        PropertyMeta ageMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        final Assignments assignments = update("ks","table").with();

        when(nameMeta.structure().isStaticColumn()).thenReturn(false);
        when(ageMeta.structure().isStaticColumn()).thenReturn(false);
        when(nameMeta.forStatementGeneration().prepareUpdateField(conditionsCaptor.capture())).thenReturn(assignments);
        when(ageMeta.forStatementGeneration().prepareUpdateField(isA(Assignments.class))).thenReturn(assignments);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, false)).thenReturn(assignments.where(eq("id", bindMarker("id"))));
        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareUpdateFields(session, meta, asList(nameMeta, ageMeta),
                ifConditions(new CASCondition("name", "John")).withTimestamp(100L));
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_remove_all_collection_and_map_with_options() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(REMOVE_COLLECTION_OR_MAP);
        when(changeSet.generateUpdateForRemoveAll(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_add_elements_to_set() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(ADD_TO_SET);
        when(changeSet.generateUpdateForAddedElements(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_remove_elements_from_set() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(REMOVE_FROM_SET);
        when(changeSet.generateUpdateForRemovedElements(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_append_elements_to_list() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(APPEND_TO_LIST);
        when(changeSet.generateUpdateForAppendedElements(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_prepend_elements_to_list() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(PREPEND_TO_LIST);
        when(changeSet.generateUpdateForPrependedElements(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_remove_elements_from_list() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(REMOVE_FROM_LIST);
        when(changeSet.generateUpdateForRemoveListElements(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_add_entries_to_map() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(ADD_TO_MAP);
        when(changeSet.generateUpdateForAddedEntries(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

    }

    @Test
    public void should_prepare_statement_to_remove_entry_from_map() throws Exception {
        //Given
        final Assignments assignments = update("table").with();

        when(changeSet.getChangeType()).thenReturn(REMOVE_FROM_MAP);
        when(changeSet.generateUpdateForRemovedKey(conditionsCaptor.capture())).thenReturn(assignments);
        when(changeSet.getPropertyMeta().structure().isStaticColumn()).thenReturn(true);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, true)).thenReturn(update("ks","table").where());
View Full Code Here

TOP

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

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.