AsahInterestTermProvider { public String[] getInterestTerms(long companyId, String userId) { String[] cachedInterestTerms = _asahInterestTermCache.getInterestTerms( userId); if (cachedInterestTerms == null) { if (_log.isDebugEnabled()) { _log.debug( "Asah interest terms cache not found for user ID " + userId); } _sendMessage(companyId, userId); return new String[0]; } return cachedInterestTerms; }  String[] getInterestTerms(long companyId, String userId);  }
@Test public void testGetInterestTermsWithCachedTerms() { String userId = RandomTestUtil.randomString(); String[] interestTerms = { RandomTestUtil.randomString(), RandomTestUtil.randomString() }; Mockito.when( _asahInterestTermCache.getInterestTerms(userId) ).thenReturn( interestTerms ); Assert.assertArrayEquals( interestTerms, _asahInterestTermProvider.getInterestTerms( RandomTestUtil.randomLong(), userId)); Mockito.verify( _messageBus, Mockito.never() ).sendMessage( Mockito.anyString(), Mockito.any(Message.class) ); }
@Test public void testGetInterestTermsWithEmptyAcClientUserId() { Assert.assertArrayEquals( new String[0], _asahInterestTermProvider.getInterestTerms( RandomTestUtil.randomLong(), StringPool.BLANK)); }
@Test public void testGetInterestTermsWithUncachedTerms() { String userId = RandomTestUtil.randomString(); Mockito.when( _asahInterestTermCache.getInterestTerms(userId) ).thenReturn( null ); Assert.assertArrayEquals( new String[0], _asahInterestTermProvider.getInterestTerms( RandomTestUtil.randomLong(), userId)); Mockito.verify( _messageBus, Mockito.times(1) ).sendMessage( Mockito.anyString(), Mockito.any(Message.class) ); }