Exemple #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);
    }
Exemple #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();
    }
Exemple #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();
    }
Exemple #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();
    }
Exemple #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();
    }
Exemple #6
0
 @Test
 public void itHasAnEntityClass() throws Exception {
   assertThat(dao.getEntityClass(), is(sameInstance(String.class)));
 }
Exemple #7
0
 @Test
 public void itGetsASessionFromTheInjectedProvider() throws Exception {
   assertThat(dao.getSession(), is(sameInstance(session)));
 }
Exemple #8
0
    @Test
    public void itPersistsEntities() throws Exception {
      assertThat(dao.save("woo"), is("woo"));

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

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

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