Package org.springframework.data.mapping

Examples of org.springframework.data.mapping.PreferredConstructor


  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiatesTypeWithPreferredConstructorUsingParameterValueProvider() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<Foo, P>(Foo.class).getConstructor();

    when(entity.getType()).thenReturn((Class) Foo.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

    Object instance = INSTANCE.createInstance(entity, provider);

    assertTrue(instance instanceof Foo);
    verify(provider, times(1)).getParameterValue((Parameter) constructor.getParameters().iterator().next());
  }
View Full Code Here


   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjCtorDefault() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjCtorDefault, P>(ObjCtorDefault.class)
        .getConstructor();

    when(entity.getType()).thenReturn((Class) ObjCtorDefault.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjCtorNoArgs() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjCtorNoArgs, P>(ObjCtorNoArgs.class)
        .getConstructor();

    when(entity.getType()).thenReturn((Class) ObjCtorNoArgs.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjCtor1ParamString() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjCtor1ParamString, P>(
        ObjCtor1ParamString.class).getConstructor();

    when(entity.getType()).thenReturn((Class) ObjCtor1ParamString.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjCtor2ParamStringString() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjCtor2ParamStringString, P>(
        ObjCtor2ParamStringString.class).getConstructor();

    when(entity.getType()).thenReturn((Class) ObjCtor2ParamStringString.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjectCtor1ParamInt() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjectCtor1ParamInt, P>(
        ObjectCtor1ParamInt.class).getConstructor();

    when(entity.getType()).thenReturn((Class) ObjectCtor1ParamInt.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

   */
  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiateObjectCtor7ParamsString5IntsString() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<ObjectCtor7ParamsString5IntsString, P>(
        ObjectCtor7ParamsString5IntsString.class).getConstructor();

    when(entity.getType()).thenReturn((Class) ObjectCtor7ParamsString5IntsString.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

View Full Code Here

  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void instantiatesTypeWithPreferredConstructorUsingParameterValueProvider() {

    PreferredConstructor constructor = new PreferredConstructorDiscoverer<Foo, P>(Foo.class).getConstructor();

    when(entity.getType()).thenReturn((Class) Foo.class);
    when(entity.getPersistenceConstructor()).thenReturn(constructor);

    Object instance = INSTANCE.createInstance(entity, provider);

    assertTrue(instance instanceof Foo);
    verify(provider, times(1)).getParameterValue((Parameter) constructor.getParameters().iterator().next());
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mapping.PreferredConstructor

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.