TraversData { protected boolean isResourceValid(Resource resource) { try { ValueMap values = resource.getValueMap(); return values.get(JcrConstants.JCR_PRIMARYTYPE, String.class) != null; } catch (IllegalArgumentException e) { return false; } }  abstract void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions,
            @Nonnull StringBuilder stringBuffer, boolean dryRun);  }
@Test public void isResourceValid_valid() { when(valueMap.get(JcrConstants.JCR_PRIMARYTYPE, String.class)).thenReturn("type"); assertTrue(traversData.isResourceValid(resource)); }
@Test public void isResourceValid_invalid() { when(valueMap.get(JcrConstants.JCR_PRIMARYTYPE, String.class)).thenThrow(IllegalArgumentException.class); assertFalse(traversData.isResourceValid(resource)); }