Package com.datastax.driver.core

Examples of com.datastax.driver.core.PreparedStatement


        when(sliceQueryProperties.getEntityClass()).thenReturn(CompleteBean.class);
        when(cache.getIfPresent(cacheKey)).thenReturn(ps);

        //When
        final PreparedStatement actual = manager.getCacheForSliceSelectAndIterator(session, cache, sliceQueryProperties);

        //Then
        assertThat(actual).isSameAs(ps);
    }
View Full Code Here


        when(sliceQueryProperties.getEntityClass()).thenReturn(CompleteBean.class);
        when(cache.getIfPresent(cacheKey)).thenReturn(null);
        when(generator.prepareSelectSliceQuery(session,sliceQueryProperties)).thenReturn(ps);

        //When
        final PreparedStatement actual = manager.getCacheForSliceSelectAndIterator(session, cache, sliceQueryProperties);

        //Then
        assertThat(actual).isSameAs(ps);
        verify(cache).put(cacheKey,ps);
    }
View Full Code Here

        when(sliceQueryProperties.getEntityClass()).thenReturn(CompleteBean.class);
        when(cache.getIfPresent(cacheKey)).thenReturn(ps);

        //When
        final PreparedStatement actual = manager.getCacheForSliceDelete(session, cache, sliceQueryProperties);

        //Then
        assertThat(actual).isSameAs(ps);
    }
View Full Code Here

        when(sliceQueryProperties.getEntityClass()).thenReturn(CompleteBean.class);
        when(cache.getIfPresent(cacheKey)).thenReturn(null);
        when(generator.prepareDeleteSliceQuery(session,sliceQueryProperties)).thenReturn(ps);

        //When
        final PreparedStatement actual = manager.getCacheForSliceDelete(session, cache, sliceQueryProperties);

        //Then
        assertThat(actual).isSameAs(ps);
        verify(cache).put(cacheKey,ps);
    }
View Full Code Here

    public void should_prepare_insert_ps() throws Exception {
        PropertyMeta nameMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        when(nameMeta.getCQL3ColumnName()).thenReturn("name");
        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareInsert(session, meta, asList(nameMeta), noOptions());

        assertThat(actual).isSameAs(ps);
        verify(idMeta.forStatementGeneration()).generateInsertPrimaryKey(isA(Insert.class));
        assertThat(queryCaptor.getValue()).isEqualTo("INSERT INTO ks.table(name) VALUES (:name) USING TTL :ttl;");
    }
View Full Code Here

        when(idMeta.forStatementGeneration().generateWhereClauseForSelect(Mockito.eq(fromNullable(nameMeta)), isA(Select.class)))
                .thenReturn(select("name").from("ks","table").where(eq("id",bindMarker("id"))));

        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareSelectField(session, meta, nameMeta);

        assertThat(actual).isSameAs(ps);

        assertThat(queryCaptor.getValue()).isEqualTo("SELECT name FROM ks.table WHERE id=:id;");
    }
View Full Code Here

        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));

        assertThat(actual).isSameAs(ps);

        assertThat(conditionsCaptor.getValue().getQueryString()).isEqualTo("UPDATE ks.table IF name=:name;");
View Full Code Here

        when(idMeta.forStatementGeneration().generateWhereClauseForSelect(Mockito.eq(Optional.<PropertyMeta>absent()), isA(Select.class)))
                .thenReturn(select("name").from("ks","table").where(eq("id", bindMarker("id"))));

        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareSelectAll(session, meta);

        assertThat(actual).isSameAs(ps);
        assertThat(queryCaptor.getValue()).isEqualTo("SELECT name FROM ks.table WHERE id=:id;");
    }
View Full Code Here

        when(idMeta.forStatementGeneration().generateWhereClauseForSelect(Mockito.eq(Optional.fromNullable(nameMeta)), isA(Select.class)))
                .thenReturn(select("name").from("ks","table").where(eq("id", bindMarker("id"))));

        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareSelectAll(session, meta);

        assertThat(actual).isSameAs(ps);
        assertThat(queryCaptor.getValue()).isEqualTo("SELECT name FROM ks.table WHERE id=:id;");
    }
View Full Code Here

        assertThat(queryCaptor.getValue()).isEqualTo("DELETE FROM ks.table WHERE id=:id;");
    }

    @Test
    public void should_prepare_simple_counter_queries() throws Exception {
        PreparedStatement incrPs = mock(PreparedStatement.class);
        PreparedStatement decrPs = mock(PreparedStatement.class);
        PreparedStatement selectPs = mock(PreparedStatement.class);
        PreparedStatement deletePs = mock(PreparedStatement.class);

        when(session.prepare(queryCaptor.capture())).thenReturn(incrPs, decrPs, selectPs, deletePs);

        Map<CQLQueryType, PreparedStatement> actual = generator.prepareSimpleCounterQueryMap(session);
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.PreparedStatement

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.