Beispiel #1
0
    @Test
    public void itGetsEntitiesById() throws Exception {
      when(session.get(String.class, 200)).thenReturn("woo!");

      assertThat(dao.getInstance(200), is("woo!"));
      verify(session).get(String.class, 200);
    }
Beispiel #2
0
    @Test
    public void itReturnsUniqueListsFromQueries() throws Exception {
      when(query.list()).thenReturn(ImmutableList.of("woo"));

      assertThat(dao.getListFromQuery("query-name"), is((List<String>) ImmutableList.of("woo")));
      verify(session).getNamedQuery("query-name");
      verify(query).list();
    }
Beispiel #3
0
    @Test
    public void itReturnsUniqueListsFromCriteriaQueries() throws Exception {
      when(critera.list()).thenReturn(ImmutableList.of("woo"));

      assertThat(dao.getListFromCriteria(), is((List<String>) ImmutableList.of("woo")));
      verify(session).createCriteria(String.class);
      verify(critera).list();
    }
Beispiel #4
0
    @Test
    public void itReturnsUniqueResultsFromQueries() throws Exception {
      when(query.uniqueResult()).thenReturn("woo");

      assertThat(dao.getUniqueResultFromQuery("query-name"), is("woo"));
      verify(session).getNamedQuery("query-name");
      verify(query).uniqueResult();
    }
Beispiel #5
0
    @Test
    public void itReturnsUniqueResultsFromCriteriaQueries() throws Exception {
      when(critera.uniqueResult()).thenReturn("woo");

      assertThat(dao.getUniqueResultFromCriteria(), is("woo"));
      verify(session).createCriteria(String.class);
      verify(critera).uniqueResult();
    }
Beispiel #6
0
 @Test
 public void itHasAnEntityClass() throws Exception {
   assertThat(dao.getEntityClass(), is(sameInstance(String.class)));
 }
Beispiel #7
0
 @Test
 public void itGetsASessionFromTheInjectedProvider() throws Exception {
   assertThat(dao.getSession(), is(sameInstance(session)));
 }
Beispiel #8
0
    @Test
    public void itPersistsEntities() throws Exception {
      assertThat(dao.save("woo"), is("woo"));

      verify(session).saveOrUpdate("woo");
    }
Beispiel #9
0
    @Test
    public void itCreatesNewCriteraQueries() throws Exception {
      assertThat(dao.getCriteria(), is(critera));

      verify(session).createCriteria(String.class);
    }
Beispiel #10
0
    @Test
    public void itGetsNamedQueries() throws Exception {
      assertThat(dao.getNamedQuery("query-name"), is(query));

      verify(session).getNamedQuery("query-name");
    }