@@ -0,0 +1,3501 @@
+package com.justjournal.services;%0A%0Aimport com.justjournal.ApplicationTest;%0Aimport com.justjournal.model.EntryStatistic;%0Aimport com.justjournal.model.User;%0Aimport com.justjournal.repository.EntryRepository;%0Aimport com.justjournal.repository.EntryStatisticRepository;%0Aimport com.justjournal.repository.UserRepository;%0Aimport io.reactivex.Maybe;%0Aimport io.reactivex.Observable;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.web.WebAppConfiguration;%0A%0Aimport java.util.Collections;%0Aimport java.util.Iterator;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0A/**%0A * @author Lucas Holt%0A */%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringApplicationConfiguration(classes = ApplicationTest.class)%0A@WebAppConfiguration%0Apublic class EntryStatisticsServiceTests %7B%0A%0A    private static final String TEST_USER = %22testuser%22;%0A    private static final int TEST_YEAR = 2003;%0A%0A    private EntryStatisticService entryStatisticService;%0A%0A    @Mock%0A    private UserRepository userRepository;%0A%0A    @Mock%0A    private EntryStatisticRepository entryStatisticRepository;%0A%0A    @Mock%0A    private EntryRepository entryRepository;%0A%0A    @Mock%0A    private EntryStatistic entryStatistic;%0A%0A    @Mock%0A    private User user;%0A%0A%0A    @Before%0A    public void setupMock() %7B%0A        MockitoAnnotations.initMocks(this);%0A        entryStatisticService = new EntryStatisticService(entryStatisticRepository, entryRepository);%0A    %7D%0A%0A    @Test%0A    public void testGetEntryCounts() %7B%0A        when(entryStatisticRepository.findByUsernameOrderByYearDesc(TEST_USER)).thenReturn(Collections.singletonList(entryStatistic));%0A        when(entryStatistic.getUser()).thenReturn(user);%0A        when(entryStatistic.getCount()).thenReturn(1L);%0A        when(entryStatistic.getYear()).thenReturn(TEST_YEAR);%0A        when(user.getUsername()).thenReturn(TEST_USER);%0A%0A        Observable%3CEntryStatistic%3E o = entryStatisticService.getEntryCounts(TEST_USER);%0A        final Iterable%3CEntryStatistic%3E myIterator = o.blockingIterable();%0A        verify(entryStatisticRepository, atLeastOnce()).findByUsernameOrderByYearDesc(TEST_USER);%0A%0A        assertNotNull(myIterator);%0A%0A        Iterator%3CEntryStatistic%3E iterator = myIterator.iterator();%0A        assertTrue(iterator.hasNext());%0A%0A        EntryStatistic es = iterator.next();%0A%0A        assertEquals(TEST_USER, es.getUser().getUsername());%0A        assertEquals(TEST_YEAR, es.getYear());%0A        assertEquals(1L, es.getCount());%0A    %7D%0A%0A%0A    @Test%0A    public void testGetEntryCount() %7B%0A        when(entryStatisticRepository.findByUsernameAndYear(TEST_USER, TEST_YEAR)).thenReturn(entryStatistic);%0A        when(entryStatistic.getUser()).thenReturn(user);%0A        when(entryStatistic.getCount()).thenReturn(1L);%0A        when(entryStatistic.getYear()).thenReturn(TEST_YEAR);%0A        when(user.getUsername()).thenReturn(TEST_USER);%0A%0A        Maybe%3CEntryStatistic%3E o = entryStatisticService.getEntryCount(TEST_USER, TEST_YEAR);%0A%0A        EntryStatistic es = o.blockingGet();%0A        verify(entryStatisticRepository, atLeastOnce()).findByUsernameAndYear(TEST_USER, TEST_YEAR);%0A%0A        assertEquals(TEST_USER, es.getUser().getUsername());%0A        assertEquals(TEST_YEAR, es.getYear());%0A        assertEquals(1L, es.getCount());%0A    %7D%0A%0A%7D%0A

add some tests.