Package org.springframework.data.repository.core

Examples of org.springframework.data.repository.core.RepositoryMetadata


  }

  @Test
  public void looksUpIdClassCorrectly() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);
    assertEquals(Integer.class, metadata.getIdType());
  }
View Full Code Here


   * @see DATACMNS-442
   */
  @Test
  public void detectsIdTypeOnIntermediateRepository() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    assertEquals(Long.class, metadata.getIdType());
  }
View Full Code Here

   * @see DATACMNS-483
   */
  @Test
  public void discoversDomainTypeOnReturnTypeWrapper() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(OptionalRepository.class);

    Method method = OptionalRepository.class.getMethod("findByEmailAddress", String.class);
    assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(User.class)));
  }
View Full Code Here

   * @see DATACMNS-483
   */
  @Test
  public void discoversDomainTypeOnNestedReturnTypeWrapper() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(OptionalRepository.class);

    Method method = OptionalRepository.class.getMethod("findByLastname", String.class);
    assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(User.class)));
  }
View Full Code Here

   * @see DATACMNS-501
   */
  @Test
  public void discoversDomainAndIdTypeForIntermediateRepository() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(IdTypeFixingRepository.class);

    assertThat(metadata.getDomainType(), is(typeCompatibleWith(Object.class)));
    assertThat(metadata.getIdType(), is(typeCompatibleWith(Long.class)));
  }
View Full Code Here

  @Test
  public void discoversRepositoryBaseClassMethod() throws Exception {

    Method method = FooRepository.class.getMethod("findOne", Integer.class);
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    DefaultRepositoryInformation information = new DefaultRepositoryInformation(metadata, REPOSITORY, null);

    Method reference = information.getTargetClassMethod(method);
    assertEquals(REPOSITORY, reference.getDeclaringClass());
    assertThat(reference.getName(), is("findOne"));
View Full Code Here

  @Test
  public void discoveresNonRepositoryBaseClassMethod() throws Exception {

    Method method = FooRepository.class.getMethod("findOne", Long.class);

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    DefaultRepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    assertThat(information.getTargetClassMethod(method), is(method));
  }
View Full Code Here

  }

  @Test
  public void discoversCustomlyImplementedCrudMethod() throws SecurityException, NoSuchMethodException {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class,
        customImplementation.getClass());

    Method source = FooRepositoryCustom.class.getMethod("save", User.class);
    Method expected = customImplementation.getClass().getMethod("save", User.class);
View Full Code Here

  }

  @Test
  public void considersIntermediateMethodsAsFinderMethods() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    assertThat(information.hasCustomMethod(), is(false));
  }
View Full Code Here

   * @see DATACMNS-151
   */
  @Test
  public void doesNotConsiderManuallyDefinedSaveMethodAQueryMethod() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(CustomRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class,
        null);
    assertThat(information.getQueryMethods(), is(IsEmptyIterable.<Method> emptyIterable()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.repository.core.RepositoryMetadata

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.