Package org.springframework.data.repository.core

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


   * @see DATACMNS-453
   */
  @Test
  public void nonPageableRepository() {

    RepositoryMetadata metadata = new DummyRepositoryMetadata(UserRepository.class);
    assertThat(metadata.isPagingRepository(), is(false));
  }
View Full Code Here


   * @see DATACMNS-453
   */
  @Test
  public void pageableRepository() {

    RepositoryMetadata metadata = new DummyRepositoryMetadata(PagedRepository.class);
    assertThat(metadata.isPagingRepository(), is(true));
  }
View Full Code Here

  /**
   * @see DATACMNS-98
   */
  @Test
  public void determinesReturnTypeFromGenericType() throws Exception {
    RepositoryMetadata metadata = new DummyRepositoryMetadata(ExtendingRepository.class);
    Method method = ExtendingRepository.class.getMethod("someMethod");
    assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(GenericType.class)));
  }
View Full Code Here

   * @see DATACMNS-98
   */
  @Test
  public void handlesGenericTypeInReturnedCollectionCorrectly() throws SecurityException, NoSuchMethodException {

    RepositoryMetadata metadata = new DummyRepositoryMetadata(ExtendingRepository.class);
    Method method = ExtendingRepository.class.getMethod("anotherMethod");
    assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(Map.class)));
  }
View Full Code Here

   * @see DATACMNS-471
   */
  @Test
  public void detectsArrayReturnTypeCorrectly() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(PagedRepository.class);
    Method method = PagedRepository.class.getMethod("returnsArray");

    assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(User.class)));
  }
View Full Code Here

        RepositoryWithDeleteMethodForEntityOverloaded.class.getMethod("delete", Domain.class));
  }

  private static CrudMethods getMethodsFor(Class<?> repositoryInterface) {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class,
        null);

    return new DefaultCrudMethods(information);
  }
View Full Code Here

  }

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

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    JpaQueryMethod queryMethod = new JpaQueryMethod(repositoryMethod, metadata, extractor);
    assertThat(queryMethod.getNamedQueryName(), is("User.findByLastname"));

    Method method = UserRepository.class.getMethod("renameAllUsersTo", String.class);
View Full Code Here

  public void invalidAnnotatedQueryCausesException() throws Exception {

    QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, Key.CREATE_IF_NOT_FOUND, extractor,
        DefaultEvaluationContextProvider.INSTANCE);
    Method method = UserRepository.class.getMethod("findByFoo", String.class);
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    Throwable reference = new RuntimeException();
    when(em.createQuery(anyString())).thenThrow(reference);

    try {
View Full Code Here

  public void sholdThrowMorePreciseExceptionIfTryingToUsePaginationInNativeQueries() throws Exception {

    QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, Key.CREATE_IF_NOT_FOUND, extractor,
        DefaultEvaluationContextProvider.INSTANCE);
    Method method = UserRepository.class.getMethod("findByInvalidNativeQuery", String.class, Pageable.class);
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    exception.expect(InvalidJpaQueryMethodException.class);
    exception.expectMessage("Cannot use native queries with dynamic sorting and/or pagination in method");
    exception.expectMessage(method.toString());
View Full Code Here

    assertThat(mapping.getItemResourceRel(), is("bar"));
  }

  private static CollectionResourceMapping getResourceMappingFor(Class<?> repositoryInterface) {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);
    return new RepositoryCollectionResourceMapping(metadata);
  }
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.