aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test
diff options
context:
space:
mode:
authorKristen Kozak <sebright@google.com>2017-10-23 18:31:31 -0700
committerKristen Kozak <sebright@google.com>2017-10-23 18:33:03 -0700
commit21d0ac659fb31b958faccfabc5d0d5062edfea9e (patch)
treefaac8dcd77ae974adf146aa5e60dc4f446b7960e /api/src/test
parenta84a39ee58668a4c443c2a69425abf38afe0c49e (diff)
downloadplatform_external_opencensus-java-21d0ac659fb31b958faccfabc5d0d5062edfea9e.tar.gz
platform_external_opencensus-java-21d0ac659fb31b958faccfabc5d0d5062edfea9e.tar.bz2
platform_external_opencensus-java-21d0ac659fb31b958faccfabc5d0d5062edfea9e.zip
Make StatsRecord.record abstract.
Diffstat (limited to 'api/src/test')
-rw-r--r--api/src/test/java/io/opencensus/stats/StatsRecorderTest.java81
1 files changed, 0 insertions, 81 deletions
diff --git a/api/src/test/java/io/opencensus/stats/StatsRecorderTest.java b/api/src/test/java/io/opencensus/stats/StatsRecorderTest.java
deleted file mode 100644
index 0f94cb33..00000000
--- a/api/src/test/java/io/opencensus/stats/StatsRecorderTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.stats;
-
-import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import io.grpc.Context;
-import io.opencensus.tags.Tag;
-import io.opencensus.tags.Tag.TagString;
-import io.opencensus.tags.TagContext;
-import io.opencensus.tags.TagKey.TagKeyString;
-import io.opencensus.tags.TagValue.TagValueString;
-import io.opencensus.tags.unsafe.ContextUtils;
-import java.util.Collections;
-import java.util.Iterator;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-/** Tests for {@link StatsRecorder}. */
-@RunWith(JUnit4.class)
-public final class StatsRecorderTest {
- private static final TagString TAG =
- TagString.create(TagKeyString.create("key"), TagValueString.create("value"));
-
- private final TagContext tagContext =
- new TagContext() {
-
- @Override
- protected Iterator<Tag> getIterator() {
- return Collections.<Tag>singleton(TAG).iterator();
- }
- };
-
- @Mock private StatsRecorder statsRecorder;
- @Mock private StatsRecord statsRecord;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(statsRecorder.newRecord()).thenReturn(statsRecord);
- }
-
- @Test
- public void record_CurrentContextNotSet() {
- StatsRecord record = statsRecorder.newRecord();
- record.record();
- verify(record).recordWithExplicitTagContext(same(ContextUtils.TAG_CONTEXT_KEY.get()));
- }
-
- @Test
- public void record_CurrentContextSet() {
- Context orig = Context.current().withValue(ContextUtils.TAG_CONTEXT_KEY, tagContext).attach();
- try {
- StatsRecord record = statsRecorder.newRecord();
- record.record();
- verify(record).recordWithExplicitTagContext(same(tagContext));
- } finally {
- Context.current().detach(orig);
- }
- }
-}