package com.a.eye.skywalking.trace.tag;

import com.a.eye.skywalking.trace.Span;
import org.junit.Assert;
import org.junit.Test;

/**
 * @author wusheng
 */
public class TagsTest {
    @Test
    public void testLayer(){
        Span span = new Span(1, "/test");
        Tags.SPAN_LAYER.asDB(span);
        Assert.assertEquals("db", span.getTag("span.layer"));

        Tags.SPAN_LAYER.asRPCFramework(span);
        Assert.assertEquals("rpc", span.getTag("span.layer"));

        Tags.SPAN_LAYER.asHttp(span);
        Assert.assertEquals("http", span.getTag("span.layer"));
    }

    @Test
    public void testBooleanTag(){
        BooleanTag tag = new BooleanTag("test.key", false);
        Span span = new Span(1, "/test");
        Assert.assertFalse(tag.get(span));

        tag.set(span, true);
        Assert.assertTrue(tag.get(span));
    }

    @Test
    public void testIntTag(){
        IntTag tag = new IntTag("test.key");
        Span span = new Span(1, "/test");
        Assert.assertNull(tag.get(span));

        tag.set(span, 123);
        Assert.assertEquals(123, tag.get(span).intValue());
    }

    @Test
    public void testShortTag(){
        ShortTag tag = new ShortTag("test.key");
        Span span = new Span(1, "/test");
        Assert.assertNull(tag.get(span));

        short value = 123;
        tag.set(span, value);
        Assert.assertEquals(value, tag.get(span).intValue());
    }
}

Add tags test case.