Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
273,400
void (final String oldClassName, final String newClassName, final String changes) { final NameSuggester suggester = new NameSuggester(oldClassName, newClassName); assertEquals( changes, suggester.getChanges().toString() ); }
doChangesTest
273,401
void (final String oldClassName, final String newClassName, final String variableName, final String expectedSuggestion) { final NameSuggester suggester = new NameSuggester(oldClassName, newClassName); assertEquals(expectedSuggestion, suggester.suggestName(variableName)); }
doSuggestionTest
273,402
void () { System.clearProperty("jb.vmOptionsFile"); }
tearDown
273,403
void () { assertEquals(512, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false)); assertEquals(128, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false)); }
reading
273,404
void () { VMOptions.parseMemoryOption("1b"); }
parsingInvalidMemoryOption
273,405
void () { String content = "*".repeat(1024); Attachment attachment = new Attachment("pure text.txt", content); assertThat(attachment.getDisplayText()).isEqualTo(content); assertThat(attachment.getBytes()).isEqualTo(content.getBytes(StandardCharsets.UTF_8)); }
stringContent
273,406
void () { assertEquals(HEAP, DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError())); assertEquals(HEAP, DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError("whatever"))); assertNull(DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError("unable to create new native thread"))); assertNull(DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError("unable to create native thread: ... limits reached"))); assertEquals(METASPACE, DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError("Metaspace"))); assertEquals(DIRECT_BUFFERS, DefaultIdeaErrorLogger.getOOMErrorKind(new OutOfMemoryError("Cannot reserve X bytes of direct buffer memory ..."))); assertEquals(CODE_CACHE, DefaultIdeaErrorLogger.getOOMErrorKind(new InternalError("CodeCache is full"))); }
test
273,407
void () { assumeWindows(); assertNotNull(WindowsDefenderChecker.getInstance().isRealTimeProtectionEnabled()); }
defenderStatusDetection
273,408
void () { Element root = new Element("root"); root.addContent(new Text("$MACro1$ some text $macro2$ other text $MACRo3$")); root.addContent(new Text("$macro4$ some text")); root.addContent(new Text("some text$macro5$")); root.addContent(new Text("file:$mac_ro6$")); root.addContent(new Text("jar://$macr.o7$ ")); root.addContent(new Text("$mac-ro8$ ")); root.addContent(new Text("$$$ ")); root.addContent(new Text("$c:\\a\\b\\c$ ")); root.addContent(new Text("$Revision 1.23$")); root.addContent(new Text("file://$root$/some/path/just$file$name.txt")); final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl(false)); UsefulTestCase.assertSameElements(macros, "MACro1", "macro4", "mac_ro6", "macr.o7", "mac-ro8", "root"); }
testCollectMacros
273,409
void () { Element root = new Element("root"); final Element configuration = new Element("configuration"); configuration.setAttribute("value", "some text$macro5$fdsjfhdskjfsd$MACRO$"); configuration.setAttribute("value2", "file://$root$/some/path/just$file$name.txt"); root.addContent(configuration); final Set<String> macros = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() { @Override public boolean recursePathMacros(@NotNull Attribute attribute) { return "value".equals(attribute.getName()); } }, new PathMacrosImpl(false)); UsefulTestCase.assertSameElements(macros, "macro5", "MACRO", "root"); }
testWithRecursiveFilter
273,410
boolean (@NotNull Attribute attribute) { return "value".equals(attribute.getName()); }
recursePathMacros
273,411
void () { Element root = new Element("root"); final Element testTag = new Element("test"); testTag.setAttribute("path", "$MACRO$"); testTag.setAttribute("ignore", "$PATH$"); root.addContent(testTag); final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl(false)); assertEquals(2, macros.size()); assertTrue(macros.contains("MACRO")); assertTrue(macros.contains("PATH")); final Set<String> filtered = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() { @Override public boolean skipPathMacros(@NotNull Attribute attribute) { return "ignore".equals(attribute.getName()); } }, new PathMacrosImpl(false)); assertEquals(1, filtered.size()); assertTrue(macros.contains("MACRO")); }
testWithFilter
273,412
boolean (@NotNull Attribute attribute) { return "ignore".equals(attribute.getName()); }
skipPathMacros
273,413
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "52", "6"}, new String[]{"7", "8", "9"} ); }
test1
273,414
void () { doTest( new String[]{"1", "1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "52", "6"}, new String[]{"7", "8", "9"} ); }
test2
273,415
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test3
273,416
void () { doTest( new String[]{}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test4
273,417
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test5
273,418
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test6
273,419
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{} ); }
test7
273,420
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"44", "4", "5", "6", "66"}, new String[]{"7", "8", "9"} ); }
test8
273,421
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"44", "4", "55", "6", "66"}, new String[]{"7", "8", "9"} ); }
test9
273,422
void () { doTest( new String[]{"0.5", "1", "3", "3.5"}, new String[]{"4", "5", "5.5", "6"}, new String[]{"6,5", "7", "8", "9", "9.5"}, new String[]{"+0.5", "1", "2", "3", "3.5+", "3.5++"}, new String[]{"4", "5", "5.5+", "6"}, new String[]{"+6,5", "++6,5", "7", "9", "9.5+", "9.5++"} ); }
test10
273,423
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"a", "a"}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"b"}, new String[]{"7", "8", "9"} ); }
test11
273,424
void () { doTest( new String[]{"1", "2", "3"}, new String[]{}, new String[]{"7", "8", "9"}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test12
273,425
void () { doTest( new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"}, new String[]{}, new String[]{"4", "52", "6"}, new String[]{} ); }
test13
273,426
void () { doTest( new String[]{}, new String[]{"4", "52", "6"}, new String[]{}, new String[]{"1", "2", "3"}, new String[]{"4", "5", "6"}, new String[]{"7", "8", "9"} ); }
test14
273,427
void () { doTest( new String[]{}, new String[]{"x", "y", "z"}, new String[]{}, new String[]{"1"}, new String[]{"2", "3"}, new String[]{"4"} ); doTest( new String[]{"1"}, new String[]{"0"}, new String[]{"3"}, new String[]{"1", "4"}, new String[]{"5", "0"}, new String[]{"3"} ); doTest( new String[]{"1", "2"}, new String[]{"3", "5", "X", "Z", "7"}, new String[]{"8", "9"}, new String[]{"1", "2"}, new String[]{"3", "4", "5", "6", "7"}, new String[]{"8", "9"} ); doTest( new String[]{"1"}, new String[]{"5", "X", "Z"}, new String[]{"9"}, new String[]{"1", "2"}, new String[]{"3", "4", "5", "6", "7"}, new String[]{"8", "9"} ); doTest( new String[]{"1"}, new String[]{"5", "X", "7"}, new String[]{"Z", "9"}, new String[]{"1", "2"}, new String[]{"3", "4", "5", "6", "7"}, new String[]{"8", "9"} ); }
testGreediness
273,428
void () { doTest( new String[]{}, new String[]{}, new String[]{}, new String[]{}, new String[]{}, new String[]{} ); doTest( new String[]{}, new String[]{}, new String[]{}, new String[]{}, new String[]{}, new String[]{"x"} ); doTest( new String[]{}, new String[]{}, new String[]{}, new String[]{"x"}, new String[]{}, new String[]{} ); doTest( new String[]{}, new String[]{}, new String[]{}, new String[]{}, new String[]{"x"}, new String[]{} ); doTest( new String[]{}, new String[]{}, new String[]{}, new String[]{"z"}, new String[]{"x"}, new String[]{"y"} ); }
testEmptyPreviousText
273,429
void () { doTest( new String[]{}, new String[]{}, new String[]{"x"}, new String[]{}, new String[]{}, new String[]{} ); doTest( new String[]{}, new String[]{}, new String[]{"x", "y", "z"}, new String[]{}, new String[]{}, new String[]{} ); doTest( new String[]{}, new String[]{}, new String[]{"x"}, new String[]{}, new String[]{}, new String[]{"z"} ); doTest( new String[]{}, new String[]{}, new String[]{"x"}, new String[]{}, new String[]{}, new String[]{"y", "z"} ); doTest( new String[]{"x"}, new String[]{}, new String[]{}, new String[]{"y"}, new String[]{}, new String[]{"z"} ); doTest( new String[]{"y"}, new String[]{}, new String[]{"w", "z"}, new String[]{"y"}, new String[]{}, new String[]{"z"} ); }
testEmptyCurrentRange
273,430
void () { Block block = new Block("0\n1\n2\n3\n4\n5\n6", 3, 7); String blockContent = block.getBlockContent(); assertEquals("3\n4\n5\n6", blockContent); block = new Block("0\n1\n2\n3\n4\n5\n6\n", 3, 7); blockContent = block.getBlockContent(); assertEquals("3\n4\n5\n6", blockContent); }
testContent
273,431
void ( String[] beforePrevBlock, String[] prevBlock, String[] afterPrevBlock, String[] beforeBlock, String[] block, String[] afterBlock) { String[] prevVersion = composeVersion(beforePrevBlock, prevBlock, afterPrevBlock); String[] currentVersion = composeVersion(beforeBlock, block, afterBlock); Block actualBlock = new Block(currentVersion, beforeBlock.length, beforeBlock.length + block.length).createPreviousBlock(prevVersion); Block expectedBlock = new Block(prevVersion, beforePrevBlock.length, beforePrevBlock.length + prevBlock.length); assertEquals(expectedBlock, actualBlock); }
doTest
273,432
String[] (String[] beforeBlock, String[] block, String[] afterBlock) { List<String> beforeList = new ArrayList<>(); ContainerUtil.addAll(beforeList, beforeBlock); ContainerUtil.addAll(beforeList, block); ContainerUtil.addAll(beforeList, afterBlock); return ArrayUtilRt.toStringArray(beforeList); }
composeVersion
273,433
void () { int N = 10_000; List<Integer> things = new ArrayList<>(N); int sum = 0; for (int i = 0; i < N; i++) { int v = i < N-50 ? 1 : 1000; things.add(v); sum += v; } //noinspection PointlessArithmeticExpression assertEquals((N-50)*1 + 50*1000, sum); long elapsed = TimeoutUtil.measureExecutionTime(() -> assertTrue(JobLauncher.getInstance().invokeConcurrentlyUnderProgress(things, new ProgressIndicatorBase(), o -> { if (o <= 1) { busySleepAndIncrement(o); } else { longSleep(o); } return true; }))); long expected = sum / JobSchedulerImpl.getJobPoolParallelism(); String message = "Elapsed: " + elapsed + "; expected: " + expected + "; parallelism=" + JobSchedulerImpl.getJobPoolParallelism() + "; current cores=" + Runtime.getRuntime().availableProcessors(); assertTrue(message, elapsed <= 2 * expected); }
testUnbalancedTaskJobUtilPerformance
273,434
void (int o) { busySleepAndIncrement(o); }
longSleep
273,435
int (int ms) { return busySleepAndIncrement(ms, EmptyRunnable.getInstance()); }
busySleepAndIncrement
273,436
int (int ms, @NotNull Runnable doWhileWait) { long deadline = System.currentTimeMillis() + ms; int nap = Math.max(1, ms / 100); while (System.currentTimeMillis() < deadline) { TimeoutUtil.sleep(nap); doWhileWait.run(); } return COUNT.incrementAndGet(); }
busySleepAndIncrement
273,437
void (@NotNull Runnable r) { LOG.debug("Elapsed: " + TimeoutUtil.measureExecutionTime(r::run) + "ms"); }
logElapsed
273,438
void () { int N = Timings.adjustAccordingToMySpeed(40, true); List<String> list = Collections.nCopies(N, null); for (int i = 0; i<10 && checkTestTimeout(i); i++) { COUNT.set(0); logElapsed(()-> JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, __ -> { JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, ___ -> { COUNT.incrementAndGet(); return true; }); return true; })); assertEquals(list.size()*list.size(), COUNT.get()); } }
testJobUtilRecursiveStress
273,439
void () { checkExceptionBubblesUp(new RuntimeException("myMsg")); checkExceptionBubblesUp(new MyException("myMsg")); checkExceptionBubblesUp(new Error("myMsg")); checkExceptionBubblesUp(new IncorrectOperationException("myMsg")); //checkExceptionBubblesUp(new ProcessCanceledException()); }
testThrowExceptionInProcessorMustBubbleUpToInvokeConcurrently
273,440
void (@NotNull Throwable ex) { COUNT.set(0); assertTrue(ex.getMessage().contains("myMsg")); List<Object> objects = Collections.nCopies(100_000, null); UsefulTestCase.assertThrows(ex.getClass(), "myMsg", () -> JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, __ -> { if (COUNT.incrementAndGet() == 10_000) { LOG.debug("PCE"); if (ex instanceof Error) { throw (Error)ex; } else { throw (RuntimeException)ex; } } return true; })); }
checkExceptionBubblesUp
273,441
void () { ProgressIndicator progress = new DaemonProgressIndicator(); UsefulTestCase.assertThrows(ProcessCanceledException.class, () -> JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(100_000, null), progress, __ -> { if (COUNT.incrementAndGet() == 10_000) { progress.cancel(); } return true; })); assertTrue(progress.isCanceled()); }
testIndicatorCancelMustEnsuePCE
273,442
void () { List<Object> objects = Collections.nCopies(100_000, null); boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, __ -> COUNT.incrementAndGet() != 10_000); assertFalse(success); }
testReturnFalseFromProcessorMustLeadToReturningFalseFromInvokeConcurrently
273,443
void () { List<Object> objects = Collections.nCopies(1_000_000, null); ApplicationManager.getApplication().runWriteAction(() -> { boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, false, __ -> { COUNT.incrementAndGet(); return true; }); assertTrue(success); assertEquals(objects.size(), COUNT.get()); }); }
testCompletesEvenIfCannotGrabReadAction
273,444
void () { List<Integer> list = IntStream.range(0, 100).boxed().collect(Collectors.toList()); for (int i = 0; i<10 && checkTestTimeout(i); i++) { int fingerPrint = i; COUNT.set(0); LOG.debug("--- " + i+"; fingerPrint="+fingerPrint+"; COUNT="+COUNT); boolean[] success = new boolean[1]; logElapsed(()-> UsefulTestCase.assertThrows(MyException.class, "myMsg", () -> success[0] = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, ind -> { boolean nestedSuccess = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, nestedInd -> { if (busySleepAndIncrement(1) % 1024 == 0) { LOG.debug("throw myMsg ind=" + ind + "; nestedInd=" + nestedInd+"; fingerPrint="+fingerPrint+"; COUNT="+COUNT); throw new MyException("myMsg"+fingerPrint+"; COUNT="+COUNT); } return true; }); LOG.debug("nestedSuccess: " + nestedSuccess + "; ind:" + ind+"; fingerPrint="+fingerPrint+"; COUNT="+COUNT); return true; }) )); assertFalse(success[0]); } }
testRecursiveCancel
273,445
void () { AtomicInteger processed = new AtomicInteger(); Processor<String> processor = __ -> { int next = processed.incrementAndGet(); busySleepAndIncrement(next % 4, ProgressManager::checkCanceled); return next % 100 != 0; }; int N = Timings.adjustAccordingToMySpeed(10_000, true); for (int i = 0; i<100 && checkTestTimeout(i); i++) { processed.set(0); ProgressIndicator indicator = new ProgressIndicatorBase(); boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(N, ""), indicator, processor); assertFalse(indicator.isCanceled()); assertFalse(result); } }
testProcessorReturningFalseDoesNotCrashTheOtherThreadStress
273,446
void (@NotNull String TOMB_STONE, @NotNull BlockingQueue<String> queue, @NotNull Queue<String> failedQueue) { while (true) { Disposable disposable = Disposer.newDisposable(); ProgressIndicator wrapper = new DaemonProgressIndicator(); try { // avoid "attach listener"/"write action" race ReadAction.run(() -> { wrapper.start(); ProgressIndicatorUtils.forceWriteActionPriority(wrapper, disposable); // there is a chance we are racing with write action, in which case just registered listener might not be called, retry. if (ApplicationManagerEx.getApplicationEx().isWriteActionPending()) { throw new ProcessCanceledException(); } }); // use wrapper here to cancel early when write action start but do not affect the original indicator ((JobLauncherImpl)JobLauncher.getInstance()).processQueue(queue, failedQueue, wrapper, TOMB_STONE, __ -> { ReadAction.run(() -> { ProgressManager.checkCanceled(); //TimeoutUtil.sleep(1); ProgressManager.checkCanceled(); COUNT.incrementAndGet(); }); return true; }); break; } catch (ProcessCanceledException e) { // wait for write action to complete ApplicationManager.getApplication().runReadAction(EmptyRunnable.getInstance()); } finally { Disposer.dispose(disposable); } } }
processQueueInBackground
273,447
boolean (Object progress) { return !t.timedOut(progress); }
checkTestTimeout
273,448
void () { int parallelism = JobSchedulerImpl.getJobPoolParallelism(); // values higher than this can lead to too coarse tasks in FJP queue which means some of them may contain more than one element which means long-delay task and some short-delay tasks can be scheduled to one chunk which means some of the tasks will not be stolen for a (relatively)long time. // so it's a TODO for ApplierCompleter int N = 1 << parallelism; Integer[] times = new Integer[N]; Arrays.fill(times, 0); int longDelay = (int)TimeUnit.MINUTES.toMillis(2); for (int i=0; i<100; i++) { times[(i + N - 1) % N] = 0; times[i % N] = longDelay; AtomicInteger executed = new AtomicInteger(); DaemonProgressIndicator progress = new DaemonProgressIndicator(); UsefulTestCase.assertThrows(MyException.class, "myMsg", () -> { TestTimeOut deadline = setTimeout(2, TimeUnit.SECONDS); JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Arrays.asList(times.clone()), progress, time -> { while ((time -= 100) >= 0) { ProgressManager.checkCanceled(); TimeoutUtil.sleep(100); if (deadline.isTimedOut()) { String s = ThreadDumper.dumpThreadsToString(); throw new AssertionError("Timed out at " + time + "; parallelism:"+parallelism+"; executed:"+executed+"; threads:\n" + s); } } if (executed.incrementAndGet() >= times.length - 1) { // executed all but the slowest one throw new MyException("myMsg"); } return true; }); }); } }
testInvokeConcurrentlyMustExecuteMultipleTasksConcurrentlyEvenIfOneOfThemIsWildlySlowStress
273,449
void () { List<Integer> ints = IntStream.range(1, 123_271*JobSchedulerImpl.getJobPoolParallelism()/11).boxed().collect(Collectors.toList()); for (int i = 0; i<100 && checkTestTimeout(i); i++) { AtomicInteger executed = new AtomicInteger(); AtomicBoolean returnedFalse = new AtomicBoolean(); boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(ints, new DaemonProgressIndicator(), n -> { if (!returnedFalse.get()) { TimeoutUtil.sleep(ThreadLocalRandom.current().nextBoolean() ? 1 : 0); } executed.incrementAndGet(); if (n % 10_000 == 0) { returnedFalse.set(true); return false; } return true; }); int count = executed.get(); assertFalse(result); TestTimeOut w = setTimeout(1000, TimeUnit.MILLISECONDS); while (!w.isTimedOut()) { assertEquals(count, executed.get()); } } }
testJobWaitForTerminationAfterReturningFalseInTheMiddleOfTheExecutionWaitsUntilAllOtherTasksFinished_Stress
273,450
void () { String json = "{ \"mandatory\" : \"text\" }"; doTest(json, Class1.class, true); }
testSuccess1
273,451
void () { String json = "{ \"simple\" : \"text2\", \"mandatory\" : \"text\" }"; doTest(json, Class1.class, true); }
testSuccess2
273,452
void () { String json = "{ \"unknown\" : \"text2\", \"mandatory\" : \"text\" }"; doTest(json, Class1.class, true); }
testSuccess3
273,453
void () { String json = "null"; doTest(json, Class1.class, true); }
testSuccess4
273,454
void () { String json = "{ \"simple\" : \"text2\" }"; doTest(json, Class1.class, false); }
testFailure1
273,455
void () { String json = "{ \"unknown\" : \"text2\" }"; doTest(json, Class1.class, false); }
testFailure2
273,456
void () { String json = "{ \"mandatory\" : null }"; doTest(json, Class1.class, false); }
testFailure3
273,457
void () { String json = "{ \"mandatory\" : { \"mandatory\" : \"text\" } }"; doTest(json, Class2.class, true); }
testSuccessEnclosed1
273,458
void () { String json = "{ \"mandatory\" : { \"mandatory\" : \"text\" }, \"simple\" : { \"mandatory\" : \"text\" } }"; doTest(json, Class2.class, true); }
testSuccessEnclosed2
273,459
void () { String json = "{ \"mandatory\" : { \"mandatory\" : \"text\" }, \"simple\" : null }"; doTest(json, Class2.class, true); }
testSuccessEnclosed3
273,460
void () { String json = "{ \"simple\" : { \"mandatory\" : \"text\" } }"; doTest(json, Class2.class, false); }
testFailureEnclosed1
273,461
void () { String json = "{ \"mandatory\" : null }"; doTest(json, Class2.class, false); }
testFailureEnclosed2
273,462
void () { String json = "{ \"mandatory\" : { \"simple\" : \"text\" } }"; doTest(json, Class2.class, false); }
testFailureEnclosed3
273,463
void () { String json = "{ \"mandatory\" : { \"mandatory\" : null, \"simple\" : \"text\" } }"; doTest(json, Class2.class, false); }
testFailureEnclosed4
273,464
void () { String json = "{ \"mandatory\" : { \"mandatory\" : \"text\" }, \"simple\" : { \"simple\" : \"text\" } }"; doTest(json, Class2.class, false); }
testFailureEnclosed5
273,465
void (@NotNull String json, @NotNull Class<?> clazz, boolean expectedSuccess) { Gson gson = new GsonBuilder() .registerTypeAdapterFactory(NullCheckingFactory.INSTANCE) .create(); boolean success; try { Object result = gson.fromJson(json, clazz); success = true; } catch (JsonMandatoryException e) { success = false; } assertEquals(expectedSuccess, success); }
doTest
273,466
void () { addExposedPort(DEFAULT_PORT); }
configure
273,467
EventLogExternalSendSettings (@NotNull String productVersion) { EventLogConfigVersions version = findMajorVersion(productVersion); if (version == null) { return EMPTY; } Map<EventLogBuildType, EventLogSendConfiguration> configurations = new EnumMap<>(EventLogBuildType.class); for (EventLogConfigFilterCondition filter : version.getFilters()) { EventLogBuildType[] types = EventLogBuildType.getTypesByString(filter.releaseType); for (EventLogBuildType type : types) { EventLogBucketRange range = filter.getBucketRange(); if (range != null) { if (!configurations.containsKey(type)) { configurations.put(type, new EventLogSendConfiguration(new ArrayList<>())); } configurations.get(type).addBucketRange(range); } } } return new EventLogExternalSendSettings(version.getEndpoints(), version.getOptions(), configurations); }
toSendSettings
273,468
EventLogConfigVersions (@NotNull String productVersion) { if (versions == null || versions.isEmpty()) { return null; } return versions.stream() .filter(v -> v.majorBuildVersionBorders != null && v.majorBuildVersionBorders.accept(productVersion)) .findFirst().orElse(null); }
findMajorVersion
273,469
boolean () { return !myConfigurations.isEmpty(); }
isSendEnabled
273,470
EventLogSendConfiguration (@NotNull EventLogBuildType type) { return myConfigurations.get(type); }
getConfiguration
273,471
String (@NotNull String name) { return myEndpoints.get(name); }
getEndpoint
273,472
boolean (@Nullable String s) { return s == null || s.isEmpty(); }
isEmpty
273,473
boolean (@Nullable String s) { return !isEmpty(s); }
isNotEmpty
273,474
boolean (@Nullable String s) { if (isEmpty(s)) { return true; } for (int i = 0; i < s.length(); i++) { if (s.charAt(i) > ' ') { return false; } } return true; }
isEmptyOrSpaces
273,475
boolean (@Nullable String s1, @Nullable String s2) { //noinspection StringEquality if (s1 == s2) return true; if (s1 == null || s2 == null) return false; if (s1.length() != s2.length()) return false; return s1.equals(s2); }
equals
273,476
List<String> (@NotNull String text, char separator) { List<String> result = new ArrayList<>(); int pos = 0; int index = text.indexOf(separator, pos); while (index >= 0) { final int nextPos = index + 1; String token = text.substring(pos, index); if (token.length() != 0) { result.add(token); } pos = nextPos; index = text.indexOf(separator, pos); } if (pos < text.length()) { result.add(text.substring(pos)); } return result; }
split
273,477
String (@Nullable String str) { return str == null ? null : str.toLowerCase(Locale.ENGLISH); }
toLowerCase
273,478
int () { return getOptionAsInt(DATA_THRESHOLD); }
getThreshold
273,479
int () { return getOptionAsInt(GROUP_THRESHOLD); }
getGroupThreshold
273,480
int () { return getOptionAsInt(GROUP_ALERT_THRESHOLD); }
getGroupAlertThreshold
273,481
int () { return getOptionAsInt(MACHINE_ID_SALT_REVISION); }
getMachineIdRevision
273,482
String () { return myOptions.get(MACHINE_ID_SALT); }
getMachineIdSalt
273,483
int (@NotNull String name) { return tryParseInt(myOptions.get(name)); }
getOptionAsInt
273,484
int (@Nullable String value) { try { if (StatisticsStringUtil.isNotEmpty(value)) { return Integer.parseInt(value); } } catch (NumberFormatException e) { //ignore } return -1; }
tryParseInt
273,485
boolean (int bucket) { return from <= bucket && bucket < to; }
contains
273,486
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; EventLogBucketRange range = (EventLogBucketRange)o; return from == range.from && to == range.to; }
equals
273,487
int () { return Objects.hash(from, to); }
hashCode
273,488
void (EventLogBucketRange range) { myBuckets.add(range); }
addBucketRange
273,489
List<EventLogBucketRange> () { return myBuckets; }
getBuckets
273,490
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; EventLogSendConfiguration that = (EventLogSendConfiguration)o; return Objects.equals(myBuckets, that.myBuckets); }
equals
273,491
int () { return Objects.hash(myBuckets); }
hashCode
273,492
List<EventLogConfigFilterCondition> () { return releaseFilters != null ? releaseFilters : Collections.emptyList(); }
getFilters
273,493
EventLogBucketRange () { return isValid() ? new EventLogBucketRange(from, to) : null; }
getBucketRange
273,494
boolean () { return from != 0 || to != Integer.MAX_VALUE; }
isValid
273,495
boolean (@NotNull String current) { EventLogMajorVersion build = EventLogMajorVersion.fromString(current); if (!isValidMajorVersion(build)) { return false; } EventLogMajorVersion toVersion = EventLogMajorVersion.fromString(to); EventLogMajorVersion fromVersion = EventLogMajorVersion.fromString(from); if (!isValidMajorVersion(toVersion) && !isValidMajorVersion(fromVersion)) { return false; } return (fromVersion == null || fromVersion.compareTo(build) <= 0) && (toVersion == null || toVersion.compareTo(build) > 0); }
accept
273,496
boolean (@Nullable EventLogMajorVersion build) { if (build == null) return false; int[] components = build.getComponents(); return components.length > 0 && components[0] > 0; }
isValidMajorVersion
273,497
int[] () { return myComponents.clone(); }
getComponents
273,498
EventLogMajorVersion (@Nullable String version) { if (version == null || StatisticsStringUtil.isEmptyOrSpaces(version)) { return null; } int separator = version.indexOf('.'); if (separator > 0) { List<String> components = StatisticsStringUtil.split(version, '.'); return new EventLogMajorVersion(toIntArray(components)); } return new EventLogMajorVersion(tryParseInt(version), 0); }
fromString
273,499
int[] (List<String> components) { int componentsSize = components.size(); int size = componentsSize != 1 ? componentsSize : 2; int[] array = new int[size]; for (int i = 0; i < componentsSize; i++) { String component = components.get(i); array[i] = tryParseInt(component); } if (componentsSize < size) { array[componentsSize] = 0; } return array; }
toIntArray