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

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

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

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