/*
 * oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.gluu.oxtrust.api.attributes.test;

import static org.testng.Assert.*;

import java.net.URI;
import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.client.Client;

import org.gluu.oxtrust.api.GluuAttributeApi;
import org.gluu.oxtrust.api.proxy.AttributeProxy;
import org.gluu.oxtrust.util.OxTrustApiConstants;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.extension.rest.client.ArquillianResteasyResource;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.testng.Reporter;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.gluu.oxtrust.action.test.BaseTest;

/**
 * @author Yuriy Movchan
 *
 * @author Yuriy Movchan Date: 07/12/2018
 */
public class AttributeWebResourceTest extends BaseTest {

    @ArquillianResource
    private URI url;

    /**
     * Get all attributes via WebTarget
     */
    @RunAsClient
    @Parameters({ "webTarget" })
    @Consumes(MediaType.APPLICATION_JSON)
    @Test
    public void loadAttributes1(@Optional @ArquillianResteasyResource("restv1") final WebTarget webTarget) {

        Invocation.Builder builder= webTarget.path("/api/attributes").request(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
        List<GluuAttributeApi> allAttributes = builder.get(List.class);
        
        assertNotNull(allAttributes, "Failed to get all attributes");
        assertTrue(allAttributes.size() > 0, "List with all attributes should be not empty");
    }

    /**
     * Get all attributes via ResteasyWebTarget
     */
    @RunAsClient
    @Parameters({ "webTarget" })
    @Consumes(MediaType.APPLICATION_JSON)
    @Test
    public void loadAttributes2(@Optional @ArquillianResteasyResource("restv1") final ResteasyWebTarget webTarget) {
        AttributeProxy attributeProxy = webTarget.proxy(AttributeProxy.class);
        List<GluuAttributeApi> allAttributes = attributeProxy.getAllAttributes();

        assertNotNull(allAttributes, "Failed to get all attributes");
        assertTrue(allAttributes.size() > 0, "List with all attributes should be not empty");
    }

    /**
     * Get all attributes via Proxy
     */
    @RunAsClient
    @Parameters({ "attributeProxy" })
    @Consumes(MediaType.APPLICATION_JSON)
    @Test
    public void loadAttributes3(@Optional @ArquillianResteasyResource("restv1") final AttributeProxy attributeProxy) {
        List<GluuAttributeApi> allAttributes = attributeProxy.getAllAttributes();

        assertNotNull(allAttributes, "Failed to get all attributes");
        assertTrue(allAttributes.size() > 0, "List with all attributes should be not empty");
    }

}
@@ -218,17 +218,73 @@
 .Assert.
-*
+assertNotNull;%0Aimport static org.testng.Assert.assertTrue
 ;%0A%0Aimpor
@@ -466,43 +466,55 @@
 pe;%0A
+%0A
 import 
-javax.ws.rs.client.Clien
+org.gluu.oxtrust.action.test.BaseTes
 t;%0A
-%0A
 impo
@@ -609,58 +609,8 @@
 xy;%0A
-import org.gluu.oxtrust.util.OxTrustApiConstants;%0A
 impo
@@ -804,125 +804,8 @@
 ce;%0A
-import org.jboss.resteasy.client.jaxrs.ResteasyClient;%0Aimport org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;%0A
 impo
@@ -862,36 +862,8 @@
 et;%0A
-import org.testng.Reporter;%0A
 impo
@@ -979,54 +979,8 @@
 est;
-%0Aimport org.gluu.oxtrust.action.test.BaseTest;
 %0A%0A/*

Optimize imports