package com.example.mapping;

import com.example.frame.base.Token;
import com.example.frame.utils.IDgenerator;
import com.example.frame.utils.LocalData;
import com.example.module.admin.ent.Mapping;
import com.example.module.admin.mgr.MappingManager;
import com.example.module.admin.req.MappingCreateRequest;
import com.example.module.admin.req.MappingFindRequest;
import com.example.module.admin.rsp.MappingCreateResponse;
import com.example.module.admin.rsp.MappingFindResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import static junit.framework.TestCase.assertTrue;

@RunWith(SpringRunner.class)
@SpringBootTest
public class MappingTest {

    @Autowired
    private MappingManager mappingManager;

    @Autowired
    private Token token;

    @Test
    public void createMapping() {
        MappingCreateRequest createRequest = new MappingCreateRequest();
        createRequest.setName("测试");
        createRequest.setContext("test");
        createRequest.setLocation("test");
        MappingCreateResponse mappingCreateResponse = mappingManager.create(createRequest, token);
        assertTrue(!mappingCreateResponse.hasError());

        MappingFindRequest mappingFindRequest = new MappingFindRequest();
        MappingFindResponse mappingFindResponse = mappingManager.find(mappingFindRequest, token);
        assertTrue(!mappingFindResponse.hasError());
    }

}
