Package info.archinnov.achilles.test.integration.entity

Examples of info.archinnov.achilles.test.integration.entity.ClusteredEntityWithStaticColumn


    /////////////////////// STATIC AND NON STATIC SIMPLE COLUMNS ////////////////////////////////
    @Test
    public void should_query_static_column() throws Exception {
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        ClusteredEntityWithStaticColumn parisStreet1 = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street1"), "Paris", "rue de la paix");
        ClusteredEntityWithStaticColumn parisStreet2 = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street2"), "Paris", "avenue des Champs Elysees");

        manager.insert(parisStreet1);
        manager.insert(parisStreet2);

        List<ClusteredEntityWithStaticColumn> found = manager.sliceQuery(ClusteredEntityWithStaticColumn.class)
                .forSelect()
                .withPartitionComponents(partitionKey)
                .get(100);

        assertThat(found).hasSize(2);
        final ClusteredEntityWithStaticColumn foundParisStreet1 = found.get(0);
        final ClusteredEntityWithStaticColumn foundParisStreet2 = found.get(1);

        assertThat(foundParisStreet1.getStreet()).isEqualTo("rue de la paix");
        assertThat(foundParisStreet2.getStreet()).isEqualTo("avenue des Champs Elysees");

        ClusteredEntityWithStaticColumn lyonStreet3 = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street3"), "Lyon", "rue Lamartine");
        manager.insert(lyonStreet3);

        found = manager.sliceQuery(ClusteredEntityWithStaticColumn.class)
                .forSelect()
                .withPartitionComponents(partitionKey)
                .get(100);

        assertThat(found).hasSize(3);
        final ClusteredEntityWithStaticColumn foundLyonStreet1 = found.get(0);
        final ClusteredEntityWithStaticColumn foundLyonStreet2 = found.get(1);
        final ClusteredEntityWithStaticColumn foundLyonStreet3 = found.get(2);

        assertThat(foundLyonStreet1.getStreet()).isEqualTo("rue de la paix");
        assertThat(foundLyonStreet1.getCity()).isEqualTo("Lyon");
        assertThat(foundLyonStreet2.getStreet()).isEqualTo("avenue des Champs Elysees");
        assertThat(foundLyonStreet3.getCity()).isEqualTo("Lyon");
        assertThat(foundLyonStreet3.getStreet()).isEqualTo("rue Lamartine");
        assertThat(foundLyonStreet3.getCity()).isEqualTo("Lyon");
    }
View Full Code Here


    @Test
    public void should_update_static_and_non_static_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        ClusteredEntityWithStaticColumn parisStreet = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street1"), "Paris", "rue de la paix");

        final ClusteredEntityWithStaticColumn managed = manager.insert(parisStreet);

        //When
        managed.setStreet("rue Lamartine");
        manager.update(managed);

        //Then
        final ClusteredEntityWithStaticColumn updated = manager.find(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(updated.getCity()).isEqualTo("Paris");
        assertThat(updated.getStreet()).isEqualTo("rue Lamartine");

        //When
        updated.setCity("Lyon");
        manager.update(updated);

        final ClusteredEntityWithStaticColumn staticUpdated = manager.find(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(staticUpdated.getCity()).isEqualTo("Lyon");
        assertThat(staticUpdated.getStreet()).isEqualTo("rue Lamartine");
    }
View Full Code Here

    @Test
    public void should_lazy_load_static_and_non_static_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        ClusteredEntityWithStaticColumn parisStreet = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street1"), "Paris", "rue de la paix");

        manager.insert(parisStreet);


        //When
        ClusteredEntityWithStaticColumn proxy = manager.getProxy(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(proxy.getStreet()).isEqualTo("rue de la paix");
        assertThat(proxy.getCity()).isEqualTo("Paris");
        proxy.setStreet("rue Lamartine");
        manager.update(proxy);

        //Then
        final ClusteredEntityWithStaticColumn updated = manager.find(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(updated.getCity()).isEqualTo("Paris");
        assertThat(updated.getStreet()).isEqualTo("rue Lamartine");

        //When
        proxy = manager.getProxy(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(proxy.getStreet()).isEqualTo("rue Lamartine");
        assertThat(proxy.getCity()).isEqualTo("Paris");
        proxy.setCity("Lyon");
        manager.update(proxy);

        final ClusteredEntityWithStaticColumn staticUpdated = manager.find(ClusteredEntityWithStaticColumn.class, parisStreet.getId());
        assertThat(staticUpdated.getCity()).isEqualTo("Lyon");
        assertThat(staticUpdated.getStreet()).isEqualTo("rue Lamartine");
    }
View Full Code Here

    @Test
    public void should_delete_static_and_non_static_column() throws Exception {
        //Given
        Long partitionKey = RandomUtils.nextLong(0,Long.MAX_VALUE);
        ClusteredEntityWithStaticColumn parisStreet = new ClusteredEntityWithStaticColumn(new ClusteredKey(partitionKey, "street1"), "Paris", "rue de la paix");

        final ClusteredEntityWithStaticColumn managed = manager.insert(parisStreet);

        //When
        manager.delete(managed);

        //Then
        final ClusteredEntityWithStaticColumn found = manager.find(ClusteredEntityWithStaticColumn.class, parisStreet.getId());

        //When
        assertThat(found).isNull();
    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.integration.entity.ClusteredEntityWithStaticColumn

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.