Search in sources :

Example 21 with AfterAll

use of org.junit.jupiter.api.AfterAll in project jnosql-diana-driver by eclipse.

the class CouchbaseSetTest method afterClass.

@AfterAll
public static void afterClass() {
    CouchbaseKeyValueConfiguration configuration = new CouchbaseKeyValueConfiguration();
    BucketManagerFactory keyValueEntityManagerFactory = configuration.get();
    BucketManager keyValueEntityManager = keyValueEntityManagerFactory.getBucketManager(CouchbaseUtil.BUCKET_NAME);
    keyValueEntityManager.remove("jnosql:set");
}
Also used : BucketManager(org.jnosql.diana.api.key.BucketManager) BucketManagerFactory(org.jnosql.diana.api.key.BucketManagerFactory) AfterAll(org.junit.jupiter.api.AfterAll)

Example 22 with AfterAll

use of org.junit.jupiter.api.AfterAll in project rubia-forums by flashboss.

the class SearchTest method stop.

@AfterAll
public static void stop() {
    log.debug("stopped test");
    Response response = get(FORUMS_URL + "findCategories/1", authorization);
    List<CategoryBean> categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    CategoryRequestBean categoryRequestBean = new CategoryRequestBean();
    categoryRequestBean.setCategory(categoryBeans.stream().filter(x -> x.getTitle().equals("First Test Category")).collect(toList()).get(0));
    categoryRequestBean.setLimit(3);
    response = post(FORUMS_URL + "findPostsFromCategoryDesc", authorization, categoryRequestBean);
    List<PostBean> postBeans = response.readEntity(new GenericType<List<PostBean>>() {
    });
    assertEquals(3, postBeans.size(), "Posts size");
    response = get(FORUMS_URL + "removePost/" + postBeans.get(0).getId() + "/false", authorization);
    response = get(FORUMS_URL + "removePost/" + postBeans.get(1).getId() + "/false", authorization);
    response = get(FORUMS_URL + "removePost/" + postBeans.get(2).getId() + "/true", authorization);
    response = post(FORUMS_URL + "findPostsFromCategoryDesc", authorization, categoryRequestBean);
    postBeans = response.readEntity(new GenericType<List<PostBean>>() {
    });
    response = get(FORUMS_URL + "findTopics/1", authorization);
    List<TopicBean> topicBeans = response.readEntity(new GenericType<List<TopicBean>>() {
    });
    PosterBean posterBean = topicBeans.get(0).getPoster();
    topicBeans.forEach(x -> {
        get(FORUMS_URL + "removeTopic/" + x.getId(), authorization);
    });
    response = get(FORUMS_URL + "findTopics/1", authorization);
    topicBeans = response.readEntity(new GenericType<List<TopicBean>>() {
    });
    response = get(FORUMS_URL + "removePoster/" + posterBean.getId(), authorization);
    PosterBean removedPosterBean = response.readEntity(PosterBean.class);
    response = get(FORUMS_URL + "findPosterByUserId/" + removedPosterBean.getUserId(), authorization);
    posterBean = response.readEntity(PosterBean.class);
    response = get(FORUMS_URL + "findForums/1", authorization);
    List<ForumBean> forumBeans = response.readEntity(new GenericType<List<ForumBean>>() {
    });
    response = get(FORUMS_URL + "findCategories/1", authorization);
    categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    get(FORUMS_URL + "removeForum/" + forumBeans.get(1).getId(), authorization);
    get(FORUMS_URL + "removeCategory/" + categoryBeans.get(1).getId(), authorization);
    response.close();
}
Also used : RestCaller(it.vige.rubia.resttest.RestCaller) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) POST_SUBJECT(it.vige.rubia.search.SortBy.POST_SUBJECT) Date(java.util.Date) Logger(org.jboss.logging.Logger) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) PollBean(it.vige.rubia.dto.PollBean) TopicBean(it.vige.rubia.dto.TopicBean) AfterAll(org.junit.jupiter.api.AfterAll) Response(jakarta.ws.rs.core.Response) PostBean(it.vige.rubia.dto.PostBean) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) MessageBean(it.vige.rubia.dto.MessageBean) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ForumInstanceBean(it.vige.rubia.dto.ForumInstanceBean) PosterBean(it.vige.rubia.dto.PosterBean) CategoryRequestBean(it.vige.rubia.dto.CategoryRequestBean) CategoryBean(it.vige.rubia.dto.CategoryBean) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.jupiter.api.Test) GenericType(jakarta.ws.rs.core.GenericType) Collectors.toList(java.util.stream.Collectors.toList) Logger.getLogger(org.jboss.logging.Logger.getLogger) List(java.util.List) NORMAL(it.vige.rubia.dto.TopicType.NORMAL) ForumBean(it.vige.rubia.dto.ForumBean) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PostBean(it.vige.rubia.dto.PostBean) GenericType(jakarta.ws.rs.core.GenericType) CategoryBean(it.vige.rubia.dto.CategoryBean) PosterBean(it.vige.rubia.dto.PosterBean) TopicBean(it.vige.rubia.dto.TopicBean) Response(jakarta.ws.rs.core.Response) CategoryRequestBean(it.vige.rubia.dto.CategoryRequestBean) ForumBean(it.vige.rubia.dto.ForumBean) Arrays.asList(java.util.Arrays.asList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) AfterAll(org.junit.jupiter.api.AfterAll)

Example 23 with AfterAll

use of org.junit.jupiter.api.AfterAll in project rubia-forums by flashboss.

the class CategoryTest method stop.

@AfterAll
public static void stop() {
    log.debug("stopped test");
    Response response = get(url + "findCategories/1", authorization);
    List<CategoryBean> categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    assertEquals(3, categoryBeans.size(), "Categories size");
    response = get(url + "removeCategory/" + categoryBeans.get(1).getId(), authorization);
    response = get(url + "findCategoryById/" + categoryBeans.get(1).getId(), authorization);
    try {
        response.readEntity(CategoryBean.class);
        fail("Category not removed");
    } catch (ProcessingException ex) {
    }
    response = get(url + "removeCategory/" + categoryBeans.get(2).getId(), authorization);
    response = get(url + "findCategoryById/" + categoryBeans.get(2).getId(), authorization);
    try {
        response.readEntity(CategoryBean.class);
        fail("Category not removed");
    } catch (ProcessingException ex) {
    }
    response.close();
}
Also used : Response(jakarta.ws.rs.core.Response) CategoryBean(it.vige.rubia.dto.CategoryBean) List(java.util.List) ProcessingException(jakarta.ws.rs.ProcessingException) AfterAll(org.junit.jupiter.api.AfterAll)

Example 24 with AfterAll

use of org.junit.jupiter.api.AfterAll in project rubia-forums by flashboss.

the class AttachmentTest method stop.

@AfterAll
public static void stop() {
    log.debug("stopped test");
    Response response = get(url + "findCategories/1", authorization);
    List<CategoryBean> categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    CategoryRequestBean categoryRequestBean = new CategoryRequestBean();
    categoryRequestBean.setCategory(categoryBeans.stream().filter(x -> x.getTitle().equals("First Test Category")).collect(toList()).get(0));
    categoryRequestBean.setLimit(3);
    response = post(url + "findPostsFromCategoryDesc", authorization, categoryRequestBean);
    List<PostBean> postBeans = response.readEntity(new GenericType<List<PostBean>>() {
    });
    assertEquals(2, postBeans.size(), "Posts size");
    PostBean postBean = postBeans.get(0);
    response = post(url + "removeAttachments", authorization, postBean);
    postBean = response.readEntity(PostBean.class);
    postBean = postBeans.get(1);
    response = post(url + "removeAttachments", authorization, postBean);
    postBean = response.readEntity(PostBean.class);
    response = post(url + "findPostsFromCategoryDesc", authorization, categoryRequestBean);
    postBeans = response.readEntity(new GenericType<List<PostBean>>() {
    });
    assertTrue(postBeans.get(0).getAttachments().isEmpty());
    assertTrue(postBeans.get(1).getAttachments().isEmpty());
    get(url + "removePost/" + postBeans.get(1).getId() + "/false", authorization);
    response = get(url + "findTopics/1", authorization);
    List<TopicBean> topicBeans = response.readEntity(new GenericType<List<TopicBean>>() {
    });
    assertEquals(1, topicBeans.size(), "Topics size");
    PosterBean posterBean = topicBeans.get(0).getPoster();
    topicBeans.forEach(x -> {
        get(url + "removeTopic/" + x.getId(), authorization);
    });
    response = get(url + "removePoster/" + posterBean.getId(), authorization);
    PosterBean removedPosterBean = response.readEntity(PosterBean.class);
    assertNotNull(removedPosterBean, "Poster removed by poster operations");
    response = get(url + "findForums/1", authorization);
    List<ForumBean> forumBeans = response.readEntity(new GenericType<List<ForumBean>>() {
    });
    assertEquals(3, forumBeans.size(), "Forums size");
    response = get(url + "findCategories/1", authorization);
    categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    assertEquals(2, categoryBeans.size(), "Categories size");
    get(url + "removeForum/" + forumBeans.get(1).getId(), authorization);
    get(url + "removeCategory/" + categoryBeans.get(1).getId(), authorization);
    response.close();
}
Also used : RestCaller(it.vige.rubia.resttest.RestCaller) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AttachmentBean(it.vige.rubia.dto.AttachmentBean) Date(java.util.Date) Logger(org.jboss.logging.Logger) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) PollBean(it.vige.rubia.dto.PollBean) TopicBean(it.vige.rubia.dto.TopicBean) AfterAll(org.junit.jupiter.api.AfterAll) Response(jakarta.ws.rs.core.Response) PostBean(it.vige.rubia.dto.PostBean) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) MessageBean(it.vige.rubia.dto.MessageBean) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ForumInstanceBean(it.vige.rubia.dto.ForumInstanceBean) PosterBean(it.vige.rubia.dto.PosterBean) CategoryRequestBean(it.vige.rubia.dto.CategoryRequestBean) CategoryBean(it.vige.rubia.dto.CategoryBean) Test(org.junit.jupiter.api.Test) GenericType(jakarta.ws.rs.core.GenericType) Collectors.toList(java.util.stream.Collectors.toList) Logger.getLogger(org.jboss.logging.Logger.getLogger) List(java.util.List) NORMAL(it.vige.rubia.dto.TopicType.NORMAL) ForumBean(it.vige.rubia.dto.ForumBean) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PostBean(it.vige.rubia.dto.PostBean) GenericType(jakarta.ws.rs.core.GenericType) CategoryBean(it.vige.rubia.dto.CategoryBean) PosterBean(it.vige.rubia.dto.PosterBean) TopicBean(it.vige.rubia.dto.TopicBean) Response(jakarta.ws.rs.core.Response) CategoryRequestBean(it.vige.rubia.dto.CategoryRequestBean) ForumBean(it.vige.rubia.dto.ForumBean) Arrays.asList(java.util.Arrays.asList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) AfterAll(org.junit.jupiter.api.AfterAll)

Example 25 with AfterAll

use of org.junit.jupiter.api.AfterAll in project rubia-forums by flashboss.

the class WatchTest method stop.

@AfterAll
public static void stop() {
    log.debug("stopped test");
    WatchRequestBean watchRequestBean = new WatchRequestBean();
    watchRequestBean.setIndexInstance(1);
    UserBean user = new UserBean();
    user.setId("root");
    watchRequestBean.setUser(user);
    Response response = post(url + "findForumWatches", authorization, watchRequestBean);
    Map<String, ForumWatchBean> forumWatches = response.readEntity(new GenericType<Map<String, ForumWatchBean>>() {
    });
    assertEquals(1, forumWatches.size());
    ForumWatchBean forumWatchBean = forumWatches.values().iterator().next();
    post(url + "removeWatch", authorization, forumWatchBean);
    response = post(url + "findForumWatches", authorization, watchRequestBean);
    forumWatches = response.readEntity(new GenericType<Map<String, ForumWatchBean>>() {
    });
    assertEquals(0, forumWatches.size());
    response = post(url + "findTopicWatches", authorization, watchRequestBean);
    Map<String, TopicWatchBean> topicWatches = response.readEntity(new GenericType<Map<String, TopicWatchBean>>() {
    });
    assertEquals(1, topicWatches.size());
    TopicWatchBean topicWatchBean = topicWatches.values().iterator().next();
    post(url + "removeWatch", authorization, topicWatchBean);
    response = post(url + "findTopicWatches", authorization, watchRequestBean);
    topicWatches = response.readEntity(new GenericType<Map<String, TopicWatchBean>>() {
    });
    assertEquals(0, topicWatches.size());
    response = get(url + "findTopics/1", authorization);
    List<TopicBean> topicBeans = response.readEntity(new GenericType<List<TopicBean>>() {
    });
    assertEquals(2, topicBeans.size(), "Topics size");
    PosterBean posterBean = topicBeans.get(0).getPoster();
    topicBeans.forEach(x -> {
        get(url + "removeTopic/" + x.getId(), authorization);
    });
    response = get(url + "findTopics/1", authorization);
    topicBeans = response.readEntity(new GenericType<List<TopicBean>>() {
    });
    assertEquals(0, topicBeans.size(), "Topics size");
    response = get(url + "removePoster/" + posterBean.getId(), authorization);
    PosterBean removedPosterBean = response.readEntity(PosterBean.class);
    assertNotNull(removedPosterBean, "Poster removed by poster operations");
    response = get(url + "findPosterByUserId/" + removedPosterBean.getUserId(), authorization);
    posterBean = response.readEntity(PosterBean.class);
    assertNull(posterBean, "Poster removed verified by poster operations");
    response = get(url + "findForums/1", authorization);
    List<ForumBean> forumBeans = response.readEntity(new GenericType<List<ForumBean>>() {
    });
    assertEquals(3, forumBeans.size(), "Forums size");
    response = get(url + "findCategories/1", authorization);
    List<CategoryBean> categoryBeans = response.readEntity(new GenericType<List<CategoryBean>>() {
    });
    assertEquals(2, categoryBeans.size(), "Categories size");
    get(url + "removeForum/" + forumBeans.get(1).getId(), authorization);
    get(url + "removeCategory/" + categoryBeans.get(1).getId(), authorization);
    response.close();
}
Also used : TopicWatchBean(it.vige.rubia.dto.TopicWatchBean) GenericType(jakarta.ws.rs.core.GenericType) CategoryBean(it.vige.rubia.dto.CategoryBean) PosterBean(it.vige.rubia.dto.PosterBean) WatchRequestBean(it.vige.rubia.dto.WatchRequestBean) TopicBean(it.vige.rubia.dto.TopicBean) Response(jakarta.ws.rs.core.Response) UserBean(it.vige.rubia.dto.UserBean) ForumWatchBean(it.vige.rubia.dto.ForumWatchBean) ForumBean(it.vige.rubia.dto.ForumBean) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Map(java.util.Map) AfterAll(org.junit.jupiter.api.AfterAll)

Aggregations

AfterAll (org.junit.jupiter.api.AfterAll)225 Statement (java.sql.Statement)39 File (java.io.File)36 PreparedStatement (java.sql.PreparedStatement)18 SQLServerPreparedStatement (com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement)12 Response (jakarta.ws.rs.core.Response)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 CategoryBean (it.vige.rubia.dto.CategoryBean)8 BucketManager (jakarta.nosql.keyvalue.BucketManager)8 BucketManagerFactory (jakarta.nosql.keyvalue.BucketManagerFactory)8 List (java.util.List)8 BucketManager (org.jnosql.diana.api.key.BucketManager)8 BucketManagerFactory (org.jnosql.diana.api.key.BucketManagerFactory)8 ForumBean (it.vige.rubia.dto.ForumBean)7 PosterBean (it.vige.rubia.dto.PosterBean)7 GenericType (jakarta.ws.rs.core.GenericType)7 Connection (java.sql.Connection)7 Arrays.asList (java.util.Arrays.asList)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 TopicBean (it.vige.rubia.dto.TopicBean)6