<commit_before>package test.com.qiniu.qvs;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.qvs.DeviceManager;
import com.qiniu.qvs.model.Device;
import com.qiniu.qvs.model.PatchOperation;
import com.qiniu.util.Auth;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import test.com.qiniu.TestConfig;

public class DeviceManagerTest {
    Auth auth = TestConfig.testAuth;
    private DeviceManager deviceManager;
    private Response res = null;
    private String namespaceId = "2xenzw3lpzpdz";
    private String gbId = "31011500991320000126";
    private String[] channels = {"31011500991320000126"};


    @Before
    public void setUp() throws Exception {
        this.deviceManager = new DeviceManager(auth);
    }

    @Test
    public void testCreateDevice() {
        Device device = new Device();
        device.setUsername("admin");
        device.setPassword("<PASSWORD>");
        try {
            res = deviceManager.createDevice(namespaceId, device);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testQueryDevice() {
        try {
            res = deviceManager.queryDevice(namespaceId, gbId);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testUpdateDevice() {
        PatchOperation[] patchOperation = {new PatchOperation("replace", "name", "GBTEST")};
        try {
            res = deviceManager.updateDevice(namespaceId, gbId, patchOperation);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testListDevice() {
        int offset = 0;
        int line = 3;
        int qtype = 0;
        String prefix = "310";
        String state = "notReg";
        try {
            res = deviceManager.listDevice(namespaceId, offset, line, prefix, state, qtype);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testListChannels() {
        String prefix = "310";
        try {
            res = deviceManager.listChannels(namespaceId, gbId, prefix);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testStartDevice() {
        try {
            res = deviceManager.startDevice(namespaceId, gbId, channels);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testStopDevice() {
        try {
            res = deviceManager.stopDevice(namespaceId, gbId, channels);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testDeleteDevice() {
        try {
            res = deviceManager.deleteDevice(namespaceId, gbId);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }
}<commit_msg>update test of DeviceManager<commit_after>package test.com.qiniu.qvs;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.qvs.DeviceManager;
import com.qiniu.qvs.model.Device;
import com.qiniu.qvs.model.PatchOperation;
import com.qiniu.util.Auth;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import test.com.qiniu.TestConfig;

public class DeviceManagerTest {
    Auth auth = TestConfig.testAuth;
    private DeviceManager deviceManager;
    private Response res = null;
    private String namespaceId = "2xenzw3lpzpdz";
    private String gbId = "31011500991320000127";
    private String[] channels = {"31011500991320000127"};


    @Before
    public void setUp() throws Exception {
        this.deviceManager = new DeviceManager(auth);
    }

    @Test
    public void testCreateDevice() {
        Device device = new Device();
        device.setUsername("admin");
        device.setPassword("<PASSWORD>");
        try {
            res = deviceManager.createDevice(namespaceId, device);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testQueryDevice() {
        try {
            res = deviceManager.queryDevice(namespaceId, gbId);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testUpdateDevice() {
        PatchOperation[] patchOperation = {new PatchOperation("replace", "name", "GBTEST")};
        try {
            res = deviceManager.updateDevice(namespaceId, gbId, patchOperation);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testListDevice() {
        int offset = 0;
        int line = 3;
        int qtype = 0;
        String prefix = "310";
        String state = "notReg";
        try {
            res = deviceManager.listDevice(namespaceId, offset, line, prefix, state, qtype);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            Assert.assertEquals("401", res.statusCode);
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testListChannels() {
        String prefix = "310";
        try {
            res = deviceManager.listChannels(namespaceId, gbId, prefix);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testStartDevice() {
        try {
            res = deviceManager.startDevice(namespaceId, gbId, channels);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }

    @Test
    public void testStopDevice() {
        try {
            res = deviceManager.stopDevice(namespaceId, gbId, channels);
            Assert.assertNotNull(res);
            System.out.println(res.bodyString());
        } catch (QiniuException e) {
            e.printStackTrace();
        } finally {
            if (res != null) {
                res.close();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11499272197962154, 'fraction_numerical': 0.014444071212630165, 'mean_word_length': 1.7373582592706098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5103937', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2413, 'n_words': 494}