// Path: src/main/java/com/github/vaibhavsinha/kong/exception/KongClientException.java
// public class KongClientException extends RuntimeException {
// 
//     private int code;
// 
//     private String error;
// 
//     public KongClientException(String message) {
//         super(message);
//     }
// 
//     public KongClientException(String message, int code, String error) {
//         super(message);
//         this.code = code;
//         this.error = error;
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public String getError() {
//         return error;
//     }
// }


import com.github.vaibhavsinha.kong.exception.KongClientException;
import com.github.vaibhavsinha.kong.model.admin.plugin.Plugin;
import com.github.vaibhavsinha.kong.model.admin.plugin.PluginList;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.github.vaibhavsinha.kong;



/**
 * Created by vaibhav on 12/06/17.
 *
 * Updated by fanhua on 2017-08-04.
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RetrofitPluginServiceTest  extends BaseTest {


    private String PLUGIN_ID = "61e5b656-7b68-4761-aeae-d9c94a5782c8";
    private String PLUGIN_NAME = "jwt";

    private String API_ID = "3a9fa5b9-5f99-4ab8-a949-d676becd30b3";

    @Test
    public void test11_CreatePlugin() throws IOException {
        Plugin request = new Plugin();
        request.setId(PLUGIN_ID);
        request.setApiId(API_ID); // make sure you put the valid API_ID here, if you don't put API_ID, the the plugin will take effect on all APIs
        request.setName(PLUGIN_NAME);

        Plugin response = kongClient.getPluginService().addPlugin(request);
        printJson(response);
        Assert.assertEquals(request.getName(), response.getName());
    }

    @Test
    public void test12_GetPlugin() throws IOException {
        Plugin response = kongClient.getPluginService().getPlugin(PLUGIN_ID);
        printJson(response);
        Assert.assertEquals(PLUGIN_NAME, response.getName());
    }


// Path: src/main/java/com/github/vaibhavsinha/kong/exception/KongClientException.java
// public class KongClientException extends RuntimeException {
// 
//     private int code;
// 
//     private String error;
// 
//     public KongClientException(String message) {
//         super(message);
//     }
// 
//     public KongClientException(String message, int code, String error) {
//         super(message);
//         this.code = code;
//         this.error = error;
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public String getError() {
//         return error;
//     }
// }


// Path: src/test/java/com/github/vaibhavsinha/kong/RetrofitPluginServiceTest.java
import com.github.vaibhavsinha.kong.exception.KongClientException;
import com.github.vaibhavsinha.kong.model.admin.plugin.Plugin;
import com.github.vaibhavsinha.kong.model.admin.plugin.PluginList;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

package com.github.vaibhavsinha.kong;



/**
 * Created by vaibhav on 12/06/17.
 *
 * Updated by fanhua on 2017-08-04.
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RetrofitPluginServiceTest  extends BaseTest {


    private String PLUGIN_ID = "61e5b656-7b68-4761-aeae-d9c94a5782c8";
    private String PLUGIN_NAME = "jwt";

    private String API_ID = "3a9fa5b9-5f99-4ab8-a949-d676becd30b3";

    @Test
    public void test11_CreatePlugin() throws IOException {
        Plugin request = new Plugin();
        request.setId(PLUGIN_ID);
        request.setApiId(API_ID); // make sure you put the valid API_ID here, if you don't put API_ID, the the plugin will take effect on all APIs
        request.setName(PLUGIN_NAME);

        Plugin response = kongClient.getPluginService().addPlugin(request);
        printJson(response);
        Assert.assertEquals(request.getName(), response.getName());
    }

    @Test
    public void test12_GetPlugin() throws IOException {
        Plugin response = kongClient.getPluginService().getPlugin(PLUGIN_ID);
        printJson(response);
        Assert.assertEquals(PLUGIN_NAME, response.getName());
    }


    @Test(expected = KongClientException.class)