Package info.archinnov.achilles.test.mapping.entity

Examples of info.archinnov.achilles.test.mapping.entity.CompleteBean$UserTweetKey


    }

    @Test
    public void should_exception_when_inserting_with_timestamp_and_cas_condition() throws Exception {
        //Given
        CompleteBean entity = new CompleteBean();

        exception.expect(AchillesException.class);
        exception.expectMessage("Cannot provide custom timestamp for CAS insert operations");

        //When
View Full Code Here


    }

    @Test
    public void should_refresh() throws Exception {
        // Given
        CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();
        when(context.<CompleteBean>getEntityClass()).thenReturn(CompleteBean.class);
        when(context.getPrimaryKey()).thenReturn(bean.getId());
        when(context.getEntity()).thenReturn(bean);

        when(proxifier.getInterceptor(bean)).thenReturn(proxyInterceptor);

        when(proxyInterceptor.getTarget()).thenReturn(bean);
        when(proxyInterceptor.getDirtyMap()).thenReturn(dirtyMap);
        when(proxyInterceptor.getAlreadyLoaded()).thenReturn(alreadyLoaded);
        when(context.getEntityMeta()).thenReturn(entityMeta);
        when(loader.load(context, CompleteBean.class)).thenReturn(achillesFutureEntity);
        when(context.getAllGettersExceptCounters()).thenReturn(allGettersExceptCounters);
        when(asyncUtils.transformFuture(eq(achillesFutureEntity), interceptorCaptor.capture(), eq(executorService))).thenReturn(achillesFutureEntity);
        when(asyncUtils.buildInterruptible(achillesFutureEntity)).thenReturn(achillesFutureEntity);

        // When
        final AchillesFuture<CompleteBean> actual = refresher.refresh(bean, context);

        // Then
        assertThat(actual).isSameAs(achillesFutureEntity);

        final CompleteBean actualBean = interceptorCaptor.getValue().apply(bean);
        assertThat(actualBean).isSameAs(bean);

        verify(dirtyMap).clear();
        verify(alreadyLoaded).clear();
        verify(alreadyLoaded).addAll(allGettersExceptCounters);
View Full Code Here

        verify(proxyInterceptor).setTarget(bean);
    }

    @Test(expected = AchillesStaleObjectStateException.class)
    public void should_throw_exception_when_object_staled() throws Exception {
        CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();
        refresher.updateProxyInterceptor(context, proxyInterceptor, bean, bean.getId()).apply(null);
    }
View Full Code Here

        when(entityMeta.forOperations().instanciate()).thenReturn(entity);
        when(idMeta.forRowExtraction().invokeOnRowForFields(row)).thenReturn(id);
        when(valueMeta.forRowExtraction().invokeOnRowForFields(row)).thenReturn("value");
        when(entityMeta.forOperations().instanciate()).thenReturn(entity);

        CompleteBean actual = entityMapper.mapRowToEntityWithPrimaryKey(entityMeta, row, propertiesMap, MANAGED);

        assertThat(actual).isSameAs(entity);
        verify(idMeta.forValues()).setValueToField(entity, id);
        verify(valueMeta.forValues()).setValueToField(entity, "value");
    }
View Full Code Here

    @Test
    public void should_return_null_when_no_column_found() throws Exception {
        when(row.getColumnDefinitions()).thenReturn(null);
        when(entityMeta.forOperations().instanciate()).thenReturn(entity);

        CompleteBean actual = entityMapper.mapRowToEntityWithPrimaryKey(entityMeta, row, null, MANAGED);
        assertThat(actual).isNull();
    }
View Full Code Here

    when(entityMeta.getIdMeta()).thenReturn(idMeta);
  }

  @Test
  public void should_validate() throws Exception {
    CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();

    when(proxifier.<CompleteBean> deriveBaseClass(bean)).thenReturn(CompleteBean.class);
        when(proxifier.getRealObject(bean)).thenReturn(bean);
        when(entityMetaMap.get(CompleteBean.class)).thenReturn(entityMeta);
        when(entityMeta.forOperations().getPrimaryKey(bean)).thenReturn(12L);
View Full Code Here

    entityValidator.validateEntity(bean, entityMetaMap);
  }

  @Test
  public void should_exception_when_no_id() throws Exception {
    CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();

    when(proxifier.<CompleteBean> deriveBaseClass(bean)).thenReturn(CompleteBean.class);
        when(proxifier.getRealObject(bean)).thenReturn(bean);
        when(entityMetaMap.get(CompleteBean.class)).thenReturn(entityMeta);
        when(entityMeta.forOperations().getPrimaryKey(bean)).thenReturn(null);
View Full Code Here

    entityValidator.validateEntity(bean, entityMetaMap);
  }

  @Test
  public void should_validate_clustered_id() throws Exception {
    CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();
    EmbeddedKey clusteredId = new EmbeddedKey(11L, "name");

    when(entityMeta.forOperations().getPrimaryKey(bean)).thenReturn(clusteredId);
        when(proxifier.getRealObject(bean)).thenReturn(bean);
    when(idMeta.structure().isEmbeddedId()).thenReturn(true);
View Full Code Here

    entityValidator.validateEntity(bean, entityMeta);
  }

  @Test
  public void should_validate_simple_id() throws Exception {
    CompleteBean bean = CompleteBeanTestBuilder.builder().id(12L).buid();

        when(proxifier.getRealObject(bean)).thenReturn(bean);
    when(entityMeta.forOperations().getPrimaryKey(bean)).thenReturn(12L);
    when(idMeta.structure().isEmbeddedId()).thenReturn(false);
View Full Code Here

    @Test
    public void should_extract_compound_pk_from_row() throws Exception {
        //Given
        EntityMeta entityMeta = mock(EntityMeta.class, RETURNS_DEEP_STUBS);
        CompleteBean pk = new CompleteBean();

        when(embeddedIdProperties.getCQL3ComponentClasses()).thenReturn(Arrays.<Class<?>>asList(Long.class,String.class));
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));

        Definition columnDef1 = ColumnDefinitionBuilder.buildColumnDef("ks", "table", "id", DataType.bigint());
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.mapping.entity.CompleteBean$UserTweetKey

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.