@Test public void testWhitelistedPluginIdPresentPredicateMatch() { when(status.getPlugin()).thenReturn("org.eclipse.plugin"); when(configuration.getAcceptedPluginsPatterns()) .thenReturn(newArrayList(Pattern.compile(quote("org.eclipse.plugin")))); sut = new WhitelistedPluginIdPresentPredicate(configuration); assertTrue(sut.apply(status)); }
@Test public void testAcceptProductPredicateNull() { System.clearProperty(SYSPROP_ECLIPSE_PRODUCT); when(configuration.getAcceptedProductsPatterns()) .thenReturn(newArrayList(Pattern.compile(quote("other.product.id")))); sut = new AcceptProductPredicate(configuration); assertFalse(sut.apply(status)); }
@Before public void before() { settings = ModelFactory.eINSTANCE.createSettings(); exCounter = 1; stCounter = 1; configuration = new ServerConfiguration(); configuration.setAcceptedPackages(newArrayList("org.*")); }
@Test public void testAcceptProductPredicateTrue() { System.setProperty(SYSPROP_ECLIPSE_PRODUCT, "the.eclipse.product.id"); when(configuration.getAcceptedProductsPatterns()) .thenReturn(newArrayList(Pattern.compile(quote("the.eclipse.product.id")))); sut = new AcceptProductPredicate(configuration); assertTrue(sut.apply(status)); }
@Test public void testCreateAnonymizedSendCopyAnonymizes() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); java.lang.Throwable throwable = new RuntimeException("test exception"); throwable.fillInStackTrace(); Throwable t = Reports.newThrowable(throwable); report.getStatus().setException(t); settings.setAnonymizeMessages(true); settings.setAnonymizeStrackTraceElements(true); configuration.setAcceptedPackages(new ArrayList<String>()); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy.getStatus().getMessage(), is(Constants.HIDDEN)); StackTraceElement stackTraceElement = copy.getStatus().getException().getStackTrace().get(0); assertThat(stackTraceElement.getClassName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getMethodName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getFileName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getLineNumber(), is(-1)); }