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

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


            .buildPersistenceManager();

    @Test
    public void should_apply_persist_interceptors() throws Exception {

        CompleteBean entity = builder().randomId().name("DuyHai").label("label").version(incr(2L)).buid();

        manager.insert(entity);

        assertThat(entity.getName()).isEqualTo("prePersist");
        assertThat(entity.getLabel()).isEqualTo("postPersist : label");

        Row row = session.execute("select name,label from CompleteBean where id = " + entity.getId()).one();

        assertThat(row.getString("name")).isEqualTo("prePersist");
        assertThat(row.getString("label")).isEqualTo("label");

    }
View Full Code Here


    }

    @Test
    public void should_apply_update_interceptors() throws Exception {

        CompleteBean entity = builder().randomId().buid();

        entity = manager.insert(entity);
        entity.setName("DuyHai");
        entity.setLabel("label");

        manager.update(entity);

        Row row = session.execute("select name,label from CompleteBean where id = " + entity.getId()).one();

        assertThat(row.getString("name")).isEqualTo("preUpdate");
        assertThat(row.getString("label")).isEqualTo("label");
        assertThat(entity.getName()).isEqualTo("preUpdate");
        assertThat(entity.getLabel()).isEqualTo("postUpdate");
    }
View Full Code Here

    }

    @Test
    public void should_apply_pre_delete_interceptors() throws Exception {

        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.delete(entity);

        assertThat(entity.getName()).isEqualTo("preRemove");
    }
View Full Code Here

    }

    @Test
    public void should_apply_post_delete_interceptors() throws Exception {

        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager2.delete(entity);

        assertThat(entity.getLabel()).isEqualTo("postRemove");
    }
View Full Code Here

    }

    @Test
    public void should_apply_post_load_interceptors() throws Exception {

        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.insert(entity);

        entity = manager.find(CompleteBean.class, entity.getId());

        assertThat(entity.getLabel()).isEqualTo("postLoad");
    }
View Full Code Here

    public void should_apply_interceptors_after_flush_for_batch() throws Exception {
        // Given
        final Batch batchingPM = pmf.createBatch();
        batchingPM.startBatch();

        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        // When
        batchingPM.insert(entity);

        // Then
        assertThat(entity.getName()).isEqualTo("DuyHai");
        assertThat(entity.getLabel()).isEqualTo("label");

        // When
        batchingPM.endBatch();

        // Then
        assertThat(entity.getName()).isEqualTo("prePersist");
        assertThat(entity.getLabel()).isEqualTo("postPersist : label");
    }
View Full Code Here

    }

    @Test
    public void should_apply_post_load_interceptor_on_typed_query() throws Exception {
        // Given
        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.insert(entity);

        RegularStatement statement = select().from("CompleteBean").where(eq("id",bindMarker()));

        // When
        final CompleteBean actual = manager.typedQuery(CompleteBean.class, statement,entity.getId()).getFirst();

        // Then
        assertThat(actual.getLabel()).isEqualTo("postLoad");
    }
View Full Code Here

    }

    @Test
    public void should_apply_post_load_interceptor_on_raw_typed_query() throws Exception {
        // Given
        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.insert(entity);

        RegularStatement statement = select().from("CompleteBean").where(eq("id",bindMarker()));

        // When
        final CompleteBean actual = manager.rawTypedQuery(CompleteBean.class, statement,entity.getId()).getFirst();

        // Then
        assertThat(actual.getLabel()).isEqualTo("postLoad");
    }
View Full Code Here

    assertThat(row).isNull();
  }

  @Test
  public void should_get_counter_from_raw_entity() throws Exception {
    CompleteBean bean = builder().randomId().version(CounterBuilder.incr(3L)).buid();

    assertThat(bean.getVersion().get()).isEqualTo(3L);
  }
View Full Code Here

    assertThat(bean.getVersion().get()).isEqualTo(3L);
  }

  @Test
  public void should_get_counter_from_managed__entity_after_setting_value() throws Exception {
    CompleteBean bean = builder().randomId().buid();
    bean = manager.insert(bean);

    bean.getVersion().incr(5L);

    assertThat(bean.getVersion().get()).isEqualTo(5L);
  }
View Full Code Here

TOP

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

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.