Search in sources :

Example 16 with JsonView

use of io.lumeer.api.dto.JsonView in project engine by Lumeer.

the class MongoViewDaoTest method testDeleteView.

@Test
public void testDeleteView() {
    JsonView view = prepareView();
    viewDao.databaseCollection().insertOne(view);
    assertThat(view.getId()).isNotNull();
    viewDao.deleteView(view.getId());
    View storedView = viewDao.databaseCollection().find(MongoFilters.idFilter(view.getId())).first();
    assertThat(storedView).isNull();
}
Also used : JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 17 with JsonView

use of io.lumeer.api.dto.JsonView in project engine by Lumeer.

the class MongoViewDaoTest method testUpdateViewExistingCode.

@Test
public void testUpdateViewExistingCode() {
    JsonView view = prepareView();
    viewDao.databaseCollection().insertOne(view);
    JsonView view2 = prepareView();
    view2.setCode(CODE2);
    view2.setName(NAME2);
    viewDao.databaseCollection().insertOne(view2);
    view2.setCode(CODE);
    assertThatThrownBy(() -> viewDao.updateView(view2.getId(), view2)).isInstanceOf(StorageException.class);
}
Also used : JsonView(io.lumeer.api.dto.JsonView) Test(org.junit.Test)

Example 18 with JsonView

use of io.lumeer.api.dto.JsonView in project engine by Lumeer.

the class MongoViewDaoTest method testCreateViewExistingCode.

@Test
public void testCreateViewExistingCode() {
    JsonView view = prepareView();
    viewDao.databaseCollection().insertOne(view);
    JsonView view2 = prepareView();
    view2.setName(NAME2);
    assertThatThrownBy(() -> viewDao.createView(view2)).isInstanceOf(StorageException.class);
}
Also used : JsonView(io.lumeer.api.dto.JsonView) Test(org.junit.Test)

Example 19 with JsonView

use of io.lumeer.api.dto.JsonView in project engine by Lumeer.

the class MongoViewDaoTest method testCreateView.

@Test
public void testCreateView() {
    JsonView view = prepareView();
    String id = viewDao.createView(view).getId();
    assertThat(id).isNotNull().isNotEmpty();
    assertThat(ObjectId.isValid(id)).isTrue();
    View storedView = viewDao.databaseCollection().find(MongoFilters.idFilter(id)).first();
    assertThat(storedView).isNotNull();
    assertThat(storedView.getCode()).isEqualTo(CODE);
    assertThat(storedView.getName()).isEqualTo(NAME);
    assertThat(storedView.getColor()).isEqualTo(COLOR);
    assertThat(storedView.getIcon()).isEqualTo(ICON);
    assertThat(storedView.getPermissions()).isEqualTo(PERMISSIONS);
    assertThat(storedView.getQuery()).isEqualTo(QUERY);
    assertThat(storedView.getPerspective()).isEqualTo(PERSPECTIVE);
    assertThat(storedView.getConfig()).isEqualTo(CONFIG);
}
Also used : JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 20 with JsonView

use of io.lumeer.api.dto.JsonView in project engine by Lumeer.

the class MongoViewDaoTest method prepareView.

private JsonView prepareView() {
    JsonView view = new JsonView();
    view.setCode(CODE);
    view.setName(NAME);
    view.setColor(COLOR);
    view.setIcon(ICON);
    view.setPermissions(new MorphiaPermissions(PERMISSIONS));
    view.setQuery(QUERY);
    view.setPerspective(PERSPECTIVE);
    view.setConfig(CONFIG);
    return view;
}
Also used : JsonView(io.lumeer.api.dto.JsonView) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)

Aggregations

JsonView (io.lumeer.api.dto.JsonView)22 View (io.lumeer.api.model.View)14 Test (org.junit.Test)14 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 JsonQuery (io.lumeer.api.dto.JsonQuery)3 MongoException (com.mongodb.MongoException)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)2 Permission (io.lumeer.api.model.Permission)2 StorageException (io.lumeer.storage.api.exception.StorageException)2 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)2 FindOneAndReplaceOptions (com.mongodb.client.model.FindOneAndReplaceOptions)1 JsonPermission (io.lumeer.api.dto.JsonPermission)1 Organization (io.lumeer.api.model.Organization)1 Pagination (io.lumeer.api.model.Pagination)1 Permissions (io.lumeer.api.model.Permissions)1 Project (io.lumeer.api.model.Project)1 Resource (io.lumeer.api.model.Resource)1 Role (io.lumeer.api.model.Role)1 User (io.lumeer.api.model.User)1 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)1