congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
PredicateWithTracing.withTracing
Code IndexAdd Tabnine to your IDE (free)

How to use
withTracing
method
in
com.nike.wingtips.util.asynchelperwrapper.PredicateWithTracing

Best Java code snippets using com.nike.wingtips.util.asynchelperwrapper.PredicateWithTracing.withTracing (Showing top 5 results out of 315)

origin: Nike-Inc/wingtips

@Test
public void constructors_throw_exception_if_passed_null_operator() {
  // given
  final Deque<Span> spanStackMock = mock(Deque.class);
  final Map<String, String> mdcInfoMock = mock(Map.class);
  // expect
  assertThat(catchThrowable(() -> new PredicateWithTracing(null)))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null)))
    .isInstanceOf(IllegalArgumentException.class);
  // and expect
  assertThat(catchThrowable(() -> new PredicateWithTracing(null, Pair.of(spanStackMock, mdcInfoMock))))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null, Pair.of(spanStackMock, mdcInfoMock))))
    .isInstanceOf(IllegalArgumentException.class);
  // and expect
  assertThat(catchThrowable(() -> new PredicateWithTracing(null, spanStackMock, mdcInfoMock)))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null, spanStackMock, mdcInfoMock)))
    .isInstanceOf(IllegalArgumentException.class);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void kitchen_sink_constructor_sets_fields_as_expected(boolean useStaticFactory) {
  // given
  Deque<Span> spanStackMock = mock(Deque.class);
  Map<String, String> mdcInfoMock = mock(Map.class);
  // when
  PredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(predicateMock, spanStackMock, mdcInfoMock)
                   : new PredicateWithTracing(predicateMock, spanStackMock, mdcInfoMock);
  // then
  assertThat(instance.origPredicate).isSameAs(predicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) {
  // when
  PredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(predicateMock, (Pair)null)
                   : new PredicateWithTracing(predicateMock, (Pair)null);
  // then
  assertThat(instance.origPredicate).isSameAs(predicateMock);
  assertThat(instance.spanStackForExecution).isNull();
  assertThat(instance.mdcContextMapForExecution).isNull();
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true   |   true    |   true",
  "true   |   false   |   true",
  "false  |   true    |   true",
  "false  |   false   |   true",
  "true   |   true    |   false",
  "true   |   false   |   false",
  "false  |   true    |   false",
  "false  |   false   |   false",
}, splitBy = "\\|")
@Test
public void pair_constructor_sets_fields_as_expected(
  boolean nullSpanStack, boolean nullMdcInfo, boolean useStaticFactory
) {
  // given
  Deque<Span> spanStackMock = (nullSpanStack) ? null : mock(Deque.class);
  Map<String, String> mdcInfoMock = (nullMdcInfo) ? null : mock(Map.class);
  // when
  PredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(predicateMock, Pair.of(spanStackMock, mdcInfoMock))
                   : new PredicateWithTracing(predicateMock, Pair.of(spanStackMock, mdcInfoMock)
                   );
  // then
  assertThat(instance.origPredicate).isSameAs(predicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void current_thread_info_constructor_sets_fields_as_expected(boolean useStaticFactory) {
  // given
  Tracer.getInstance().startRequestWithRootSpan("request-" + UUID.randomUUID().toString());
  Deque<Span> spanStackMock = Tracer.getInstance().getCurrentSpanStackCopy();
  Map<String, String> mdcInfoMock = MDC.getCopyOfContextMap();
  // when
  PredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(predicateMock)
                   : new PredicateWithTracing(predicateMock);
  // then
  assertThat(instance.origPredicate).isSameAs(predicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
com.nike.wingtips.util.asynchelperwrapperPredicateWithTracingwithTracing

Javadoc

Equivalent to calling new PredicateWithTracing(origPredicate) - this allows you to do a static method import for cleaner looking code in some cases. This method ultimately extracts the current tracing and MDC information from the current thread using Tracer#getCurrentSpanStackCopy() and MDC#getCopyOfContextMap(). That tracing and MDC information will be associated with the thread when the given operation is executed.

The operation you pass in cannot be null (an IllegalArgumentException will be thrown if you pass in null for the operation).

Popular methods of PredicateWithTracing

  • <init>
    Constructor that uses the given trace and MDC information, which will be associated with the thread
  • test

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • findViewById (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now