Search in sources :

Example 1 with Principal

use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.

the class CronServiceTest method principal.

private Principal principal(final long id) {
    when(principalService.getMembers()).thenReturn(new HashSet<>(Arrays.asList(id)));
    final Principal principal = new Principal(id, "Principal 1 Token", "Principal 1 Token Secret");
    when(principalService.get(id)).thenReturn(principal);
    return principal;
}
Also used : Principal(com.jeanchampemont.wtfdyum.dto.Principal)

Example 2 with Principal

use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.

the class PrincipalServiceTest method getTest.

@Test
public void getTest() {
    final Principal u = new Principal(12L, "tokdf", "secrrr");
    when(principalRedisTemplate.opsForValue()).thenReturn(valueOperations);
    when(valueOperations.get("190")).thenReturn(u);
    final Principal principal = sut.get(190L);
    assertThat(principal).isNotNull();
    assertThat(principal).isEqualTo(u);
}
Also used : Principal(com.jeanchampemont.wtfdyum.dto.Principal) Test(org.junit.Test)

Example 3 with Principal

use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.

the class TwitterServiceTest method verifyCredentialsTestFalse.

@Test
public void verifyCredentialsTestFalse() throws TwitterException {
    when(twitter.verifyCredentials()).thenThrow(new TwitterException(""));
    final boolean result = sut.verifyCredentials(new Principal(12L, "tre", "tr"));
    assertThat(result).isFalse();
}
Also used : Principal(com.jeanchampemont.wtfdyum.dto.Principal) ResponseListMockForTest(com.jeanchampemont.wtfdyum.utils.ResponseListMockForTest) Test(org.junit.Test)

Example 4 with Principal

use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.

the class TwitterServiceTest method getUsersEmptyTest.

@Test
public void getUsersEmptyTest() throws Exception {
    final List<com.jeanchampemont.wtfdyum.dto.User> result = sut.getUsers(new Principal(1L, "", ""), new long[0]);
    assertThat(result).isNotNull();
    assertThat(result.size()).isEqualTo(0);
}
Also used : Principal(com.jeanchampemont.wtfdyum.dto.Principal) ResponseListMockForTest(com.jeanchampemont.wtfdyum.utils.ResponseListMockForTest) Test(org.junit.Test)

Example 5 with Principal

use of com.jeanchampemont.wtfdyum.dto.Principal in project WTFDYUM by jchampemont.

the class TwitterServiceTest method tweetTest.

@Test
public void tweetTest() throws Exception {
    sut.tweet(new Principal(144L, "tok", "toksec"), "my brand new tweet");
    verify(twitter, times(1)).updateStatus("my brand new tweet");
}
Also used : Principal(com.jeanchampemont.wtfdyum.dto.Principal) ResponseListMockForTest(com.jeanchampemont.wtfdyum.utils.ResponseListMockForTest) Test(org.junit.Test)

Aggregations

Principal (com.jeanchampemont.wtfdyum.dto.Principal)37 Test (org.junit.Test)27 ResponseListMockForTest (com.jeanchampemont.wtfdyum.utils.ResponseListMockForTest)15 Event (com.jeanchampemont.wtfdyum.dto.Event)9 User (com.jeanchampemont.wtfdyum.dto.User)5 Random (java.util.Random)4 AccessToken (twitter4j.auth.AccessToken)4 WTFDYUMException (com.jeanchampemont.wtfdyum.utils.WTFDYUMException)3 HashSet (java.util.HashSet)2 RequestToken (twitter4j.auth.RequestToken)2 HttpSession (javax.servlet.http.HttpSession)1 Bean (org.springframework.context.annotation.Bean)1 RedisTemplate (org.springframework.data.redis.core.RedisTemplate)1 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)1 MockHttpSession (org.springframework.mock.web.MockHttpSession)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 StopWatch (org.springframework.util.StopWatch)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1