Search in sources :

Example 11 with Tag

use of org.wso2.carbon.apimgt.core.models.Tag in project carbon-apimgt by wso2.

the class TagDAOImplIT method testGetTags.

@Test(description = "Get all tags")
public void testGetTags() throws APIManagementException {
    // add tags by creating two different APIs
    API api = TestUtil.addTestAPI();
    API alternativeApi = TestUtil.addAlternativeAPI();
    // get the list of all tags from DB
    TagDAO tag = DAOFactory.getTagDAO();
    List<Tag> tagList = tag.getTags();
    Assert.assertNotNull(tagList);
    // check tags for correctness
    HashSet<String> set = new HashSet<>();
    set.addAll(api.getTags());
    set.addAll(alternativeApi.getTags());
    List<String> tagsFromDB = new ArrayList<>();
    for (Tag availableTag : tagList) {
        tagsFromDB.add(availableTag.getName());
    }
    Assert.assertTrue(set.containsAll(tagsFromDB));
    Assert.assertTrue(set.size() == tagsFromDB.size());
}
Also used : TagDAO(org.wso2.carbon.apimgt.core.dao.TagDAO) ArrayList(java.util.ArrayList) API(org.wso2.carbon.apimgt.core.models.API) Tag(org.wso2.carbon.apimgt.core.models.Tag) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Tag (org.wso2.carbon.apimgt.core.models.Tag)7 ArrayList (java.util.ArrayList)4 Test (org.testng.annotations.Test)3 TagDTO (org.wso2.carbon.apimgt.rest.api.store.dto.TagDTO)3 TagListDTO (org.wso2.carbon.apimgt.rest.api.store.dto.TagListDTO)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)2 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)2 API (org.wso2.carbon.apimgt.core.models.API)2 IOException (java.io.IOException)1 ResultSet (java.sql.ResultSet)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Response (javax.ws.rs.core.Response)1 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)1 Test (org.junit.Test)1