package com.njust.test;

import java.util.stream.Stream;

import org.junit.Assert;
import org.junit.Test;

import lombok.Getter;

public class EnumTest
{

    @Test(expected = IllegalArgumentException.class)
    public void testBasic()
    {
        Assert.assertEquals(TypeEnum.valueOf("aaa"), TypeEnum.AAA);
        Assert.assertEquals(TypeEnum.valueOf("bbb"), TypeEnum.BBB);
    }

    @Test
    public void testBasic2()
    {
        //enum.valueOf方法必须使用enum变量本身的定义，不是属性detail，而且大小写都必须一样
        Assert.assertEquals(TypeEnum.valueOf("AAA"), TypeEnum.AAA);
        Assert.assertEquals(TypeEnum.valueOf("BBB"), TypeEnum.BBB);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testEqual01()
    {
        Assert.assertEquals(TypeEnum.valueOf("--aa"), TypeEnum.AAA);
        Assert.assertEquals(TypeEnum.valueOf("--bb"), TypeEnum.BBB);
    }

    @Test
    public void testEqual02()
    {
        //2.判断相等方法1是直接字符串比较；2是自己写方法转换到enum对象
        Assert.assertEquals("--aa", TypeEnum.AAA.getDetail());
        Assert.assertEquals("--bb", TypeEnum.BBB.getDetail());
    }

    @Test
    public void testEqual03()
    {
        Assert.assertEquals(TypeEnum.from("--aa"), TypeEnum.AAA);
        Assert.assertEquals(TypeEnum.from("--bb"), TypeEnum.BBB);
    }

    @Test(expected = IllegalArgumentException.class)
    public void illegal01()
    {
        TypeEnum.valueOf("***");
    }

    @Test
    public void illegal02()
    {
        Assert.assertNull(TypeEnum.from("***"));
    }

    enum TypeEnum
    {
        AAA("--aa"),
        BBB("--bb");

        @Getter
        private String detail;

        TypeEnum(String detail)
        {
            this.detail = detail;
        }

        public static TypeEnum from(String detail)
        {
            return Stream.of(values()).filter(n -> n.detail.equals(detail)).findFirst().orElse(null);
        }
    }
}

@@ -235,32 +235,34 @@
 )%0A    %7B%0A        
+//
 Assert.assertEqu
@@ -250,38 +250,103 @@
  //Assert.assert
-Equals
+True(TypeEnum.valueOf(%22aaa%22)== TypeEnum.AAA);%0A        Assert.assertSame
 (TypeEnum.valueO
@@ -383,38 +383,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.valueO
@@ -563,38 +563,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.valueO
@@ -629,38 +629,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.valueO
@@ -791,38 +791,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.valueO
@@ -858,38 +858,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.valueO
@@ -1202,38 +1202,36 @@
    Assert.assert
-Equals
+Same
 (TypeEnum.from(%22
@@ -1274,22 +1274,20 @@
 t.assert
-Equals
+Same
 (TypeEnu

Update EnumTest.java