Пример #1
0
 private void givenFilterWith(
     String pool,
     String states,
     String status,
     boolean parent,
     boolean source,
     boolean target,
     Long updateBefore,
     Long updateAfter,
     Long scanBefore,
     Long scanAfter) {
   filter = new PoolFilter();
   filter.setLastUpdateBefore(updateBefore);
   filter.setLastUpdateAfter(updateAfter);
   filter.setLastScanBefore(scanBefore);
   filter.setLastScanAfter(scanAfter);
   filter.setParent(parent);
   filter.setPools(pool);
   filter.setPoolStatus(status);
   filter.setSource(source);
   filter.setTarget(target);
   if (states != null) {
     filter.setState(ImmutableSet.copyOf(states.split("[,]")));
   }
 }
Пример #2
0
 @Test
 public void shouldNotMatchPoolOperationWhenPoolStatusDoesNotMatch() {
   givenFilterWith(null, null, "RESTART", false, false, false, null, null, null, null);
   givenPoolOperationWith(
       System.currentTimeMillis(), System.currentTimeMillis(), "DOWN", "WAITING");
   assertFalse(filter.matches("resilient_pool-0", poolOperation));
 }
Пример #3
0
 @Test
 public void shouldMatchPoolOperationWhenPoolStateMatches() {
   givenFilterWith(null, "WAITING,RUNNING", null, false, false, false, null, null, null, null);
   givenPoolOperationWith(
       System.currentTimeMillis(), System.currentTimeMillis(), "DOWN", "WAITING");
   assertTrue(filter.matches("resilient_pool-0", poolOperation));
 }
Пример #4
0
 @Test
 public void shouldMatchPoolOperationWhenAfterUpdateMatches() {
   givenFilterWith(
       null, null, null, false, false, false, System.currentTimeMillis(), null, null, null);
   givenPoolOperationWith(
       System.currentTimeMillis(),
       System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1),
       "DOWN",
       "WAITING");
   assertTrue(filter.matches("resilient_pool-0", poolOperation));
 }
Пример #5
0
 @Test
 public void shouldNotMatchPoolOperationWhenBeforeUpdateDoesNotMatch() {
   givenFilterWith(
       null,
       null,
       "RESTART",
       false,
       false,
       false,
       System.currentTimeMillis() - TimeUnit.HOURS.toMillis(2),
       null,
       null,
       null);
   givenPoolOperationWith(
       System.currentTimeMillis(),
       System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1),
       "DOWN",
       "WAITING");
   assertFalse(filter.matches("resilient_pool-0", poolOperation));
 }
Пример #6
0
 @Test
 public void shouldMatchFileOperationWhenSourceMatchesSourcePool() throws CacheException {
   givenFilterWith("resilient_pool-0", null, null, false, true, false, null, null, null, null);
   givenFileOperationWith(null, "resilient_pool-0", null);
   assertTrue(filter.matches(fileOperation, poolInfoMap));
 }
Пример #7
0
 @Test
 public void shouldNotMatchFileOperationWhenTargetDoesNotMatchTargetPool() throws CacheException {
   givenFilterWith("resilient_pool-0", null, null, false, false, true, null, null, null, null);
   givenFileOperationWith(null, null, null);
   assertFalse(filter.matches(fileOperation, poolInfoMap));
 }