Package org.springframework.data.jpa.domain.sample

Examples of org.springframework.data.jpa.domain.sample.Role


  @Before
  public void setup() {

    tom = new User("Thomas", "Darimont", "tdarimont@example.org");
    role = new Role("Developer");
    em.persist(role);
    tom.getRoles().add(role);
  }
View Full Code Here


    Thread.sleep(10);
    thirdUser = new User("Dave", "Matthews", "no@email.com");
    thirdUser.setAge(43);
    fourthUser = new User("kevin", "raymond", "no@gmail.com");
    fourthUser.setAge(31);
    adminRole = new Role("admin");

    SampleSecurityContextHolder.clear();
  }
View Full Code Here

   * Tests, that persisting a relationsship without cascade attributes throws a {@code DataAccessException}.
   */
  @Test(expected = DataAccessException.class)
  public void testPreventsCascadingRolePersisting() {

    firstUser.addRole(new Role("USER"));

    flushTestUsers();
  }
View Full Code Here

  @Autowired RoleRepository repository;

  @Test
  public void createsRole() throws Exception {

    Role reference = new Role("ADMIN");
    Role result = repository.save(reference);
    assertThat(result, is(reference));
  }
View Full Code Here

  }

  @Test
  public void updatesRole() throws Exception {

    Role reference = new Role("ADMIN");
    Role result = repository.save(reference);
    assertThat(result, is(reference));

    // Change role name
    ReflectionTestUtils.setField(reference, "name", "USER");
    repository.save(reference);

    assertThat(repository.findOne(result.getId()), is(reference));
  }
View Full Code Here

   * @see DATAJPA-509
   */
  @Test
  public void shouldUseExplicitlyConfiguredEntityNameInOrmXmlInCountQueries() {

    Role reference = new Role("ADMIN");
    repository.save(reference);

    assertThat(repository.count(), is(1L));
  }
View Full Code Here

   * @see DATAJPA-509
   */
  @Test
  public void shouldUseExplicitlyConfiguredEntityNameInOrmXmlInExistsQueries() {

    Role reference = new Role("ADMIN");
    reference = repository.save(reference);

    assertThat(repository.exists(reference.getId()), is(true));
  }
View Full Code Here

   * @see DATAJPA-509
   */
  @Test
  public void shouldUseExplicitlyConfiguredEntityNameInDerivedCountQueries() {

    Role reference = new Role("ADMIN");
    reference = repository.save(reference);

    assertThat(repository.countByName(reference.getName()), is(1L));
  }
View Full Code Here

    repository = new QueryDslJpaRepository<User, Integer>(information, em);
    dave = repository.save(new User("Dave", "Matthews", "dave@matthews.com"));
    carter = repository.save(new User("Carter", "Beauford", "carter@beauford.com"));
    oliver = repository.save(new User("Oliver", "matthews", "oliver@matthews.com"));
    adminRole = em.merge(new Role("admin"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.jpa.domain.sample.Role

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.