import com.izouma.awesomeadmin.model.VuforiaTarget;
import com.izouma.awesomeadmin.service.UserInfoService;
import com.izouma.awesomeadmin.vuforia.VuforiaUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.GenericXmlContextLoader;
import org.springframework.transaction.annotation.Transactional;

@RunWith(value = SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/applicationContext.xml"}, loader = GenericXmlContextLoader.class)
@Transactional
public class VuforialUtilTest {

    @Test
    public void PostNewTargetTest() {
        String imageUrl = "http://oss.izouma.com/yimishijie/images/2018-12-06-09-32-37-gr89k16u.jpg";
        String targetName = "ceshiadd1";
        double width = 30.0;
        String accessKey = "391531184ed5cf0d998a91f193eddd57cff3b074";
        String secretKey = "21f5b1d95a537e501ed62baad256f44f2b1ea022";
        String targetId = VuforiaUtil.PostNewTarget(imageUrl, targetName, width, accessKey, secretKey);
        System.out.println(targetId);
    }

    @Test
    public void UpdateTargetTest() {
        String targetName = "ceshiadd2";
        double width = 20.0;
        String accessKey = "391531184ed5cf0d998a91f193eddd57cff3b074";
        String secretKey = "21f5b1d95a537e501ed62baad256f44f2b1ea022";
        String targetId = "8761cf50dc9b4e198b608c3cac8d6f27";
        String result_code = VuforiaUtil.updateTarget(targetId, targetName, width, null, accessKey, secretKey, null);
        System.out.println(result_code);
    }


    @Test
    public void GetTargetTest() {
        String accessKey = "391531184ed5cf0d998a91f193eddd57cff3b074";
        String secretKey = "21f5b1d95a537e501ed62baad256f44f2b1ea022";
        String targetId = "8761cf50dc9b4e198b608c3cac8d6f27";
        VuforiaTarget result_code = VuforiaUtil.getTarget(targetId, accessKey, secretKey);
        System.out.println(result_code);
    }

    @Test
    public void DeleteTargetTest() {
        String accessKey = "391531184ed5cf0d998a91f193eddd57cff3b074";
        String secretKey = "21f5b1d95a537e501ed62baad256f44f2b1ea022";
        String targetId = "8761cf50dc9b4e198b608c3cac8d6f27";
        String result_code = VuforiaUtil.deleteTarget(targetId, accessKey, secretKey);
        System.out.println(result_code);
    }



}
