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

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


        proxifier.ensureProxy(realProxy);
    }

    @Test
    public void should_exception_when_not_proxy() throws Exception {
        CompleteBean proxy = new CompleteBean();

        exception.expect(IllegalStateException.class);
        exception.expectMessage("The entity '" + proxy + "' is not in 'managed' state.");
        proxifier.ensureProxy(proxy);
    }
View Full Code Here


        proxifier.ensureProxy(proxy);
    }

    @Test
    public void should_ensure_not_proxy() throws Exception {
        proxifier.ensureNotProxy(new CompleteBean());
    }
View Full Code Here

        assertThat(proxifier.removeProxy((Object) null)).isNull();
    }

    @Test
    public void should_return_same_entity_when_calling_unproxy_on_non_proxified_entity() throws Exception {
        CompleteBean realObject = new CompleteBean();

        CompleteBean actual = proxifier.removeProxy(realObject);

        assertThat(actual).isSameAs(realObject);
    }
View Full Code Here

    }

    @Test
    public void should_unproxy_real_entryset() throws Exception {
        Map<Integer, CompleteBean> map = new HashMap<>();
        CompleteBean completeBean = new CompleteBean();
        map.put(1, completeBean);
        Map.Entry<Integer, CompleteBean> entry = map.entrySet().iterator().next();

        when(proxifier.isProxy(completeBean)).thenReturn(false);
View Full Code Here


    @Test
    public void should_instantiate_embeddedId_with_partition_components() throws Exception {
        //Given
        CompleteBean pk = new CompleteBean();
        List<Field> fields = Arrays.asList(CompleteBean.class.getDeclaredField("id"), CompleteBean.class.getDeclaredField("name"));
        List<Object> components = Arrays.<Object>asList(10L, "DuyHai");
        when(meta.<CompleteBean>getValueClass()).thenReturn(CompleteBean.class);
        when(meta.forValues().instantiate()).thenReturn(pk);
        when(meta.getEmbeddedIdProperties().getPartitionComponents().getComponentFields()).thenReturn(fields);

        PropertyMetaSliceQueryContext view = new PropertyMetaSliceQueryContext(meta);

        //When
        final Object actual = view.instantiateEmbeddedIdWithPartitionComponents(components);

        //Then
        assertThat(actual).isSameAs(pk);
        assertThat(pk.getId()).isEqualTo(10L);
        assertThat(pk.getName()).isEqualTo("DuyHai");
    }
View Full Code Here

    invoker.setValueToField("bean", field, "test");
  }

  @Test
  public void should_get_value_from_list_field() throws Exception {
    CompleteBean bean = new CompleteBean();
    bean.setFriends(Arrays.asList("foo", "bar"));
    Field field = CompleteBean.class.getDeclaredField("friends");

    List<String> value = invoker.getListValueFromField(bean, field);
    assertThat(value).containsExactly("foo", "bar");
  }
View Full Code Here

    assertThat(value).containsExactly("foo", "bar");
  }

  @Test
  public void should_get_value_from_set_field() throws Exception {
    CompleteBean bean = new CompleteBean();
    bean.setFollowers(Sets.newHashSet("foo", "bar"));
    Field field = CompleteBean.class.getDeclaredField("followers");

    Set<String> value = invoker.getSetValueFromField(bean, field);
    assertThat(value).containsOnly("foo", "bar");
  }
View Full Code Here

    assertThat(value).containsOnly("foo", "bar");
  }

  @Test
  public void should_get_value_from_map_field() throws Exception {
    CompleteBean bean = new CompleteBean();
    bean.setPreferences(ImmutableMap.of(1, "FR"));
    Field field = CompleteBean.class.getDeclaredField("preferences");

    Map<Integer, String> value = invoker.getMapValueFromField(bean, field);
    assertThat(value).containsKey(1).containsValue("FR");
  }
View Full Code Here

  }

  @Test
  public void should_get_primary_key() throws Exception {
    Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
    CompleteBean bean = new CompleteBean(id);

    PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).type(ID).propertyName("id")
        .accessors().build();

    Object key = invoker.getPrimaryKey(bean, idMeta);
View Full Code Here

    @Test
    public void should_generate_where_clause_for_update_with_embedded_id() throws Exception {
        //Given
        Object entity = new Object();
        CompleteBean pk = new CompleteBean();
        PropertyMeta pm = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(meta.forValues().getPrimaryKey(entity)).thenReturn(pk);

        final Assignments assignments = update("table").with();
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.mapping.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.