package org.selfstudy.javalang.common.util;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

import java.io.Serializable;
import java.util.HashMap;
import java.util.UUID;

/**
 * Created by liqingsong on 26/04/2017.
 */

public class UuidTest {

//    @org.junit.Test
    public void uuidToString() {
        System.out.println (UUID.randomUUID ( ).toString ( ).replace ("-",""));
        HashMap map = new HashMap();
    }

    @Test
    public void beanTest(){
        BeanT beanT = new BeanT();
        beanT.setUuid("aaaa");
        beanT.setTimestamp(System.currentTimeMillis());
        beanT.setNameLetter("aaabbbbccccddd");
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        String jsonStr = null;
        try {
            jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(beanT);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        System.out.println(jsonStr);
    }

    public class BeanT implements Serializable{
        @JsonProperty("UUID")
        private String uuid;
        @JsonProperty("TIMESTAMP")
        private Long timestamp;

        private String nameLetter;

        public String getUuid() {
            return uuid;
        }

        public void setUuid(String uuid) {
            this.uuid = uuid;
        }

        public Long getTimestamp() {
            return timestamp;
        }

        public void setTimestamp(Long timestamp) {
            this.timestamp = timestamp;
        }

        public String getNameLetter() {
            return nameLetter;
        }

        public void setNameLetter(String nameLetter) {
            this.nameLetter = nameLetter;
        }
    }
}
