use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testUpdateViewExistingCode.
@Test
public void testUpdateViewExistingCode() {
MorphiaView view = prepareView();
datastore.save(viewDao.databaseCollection(), view);
MorphiaView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
datastore.save(viewDao.databaseCollection(), view2);
view2.setCode(CODE);
assertThatThrownBy(() -> viewDao.updateView(view2.getId(), view2)).isInstanceOf(DuplicateKeyException.class);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testUpdateViewCode.
@Test
public void testUpdateViewCode() {
MorphiaView view = prepareView();
String id = datastore.save(viewDao.databaseCollection(), view).getId().toString();
assertThat(id).isNotNull().isNotEmpty();
view.setCode(CODE2);
viewDao.updateView(id, view);
MorphiaView storedView = datastore.get(viewDao.databaseCollection(), MorphiaView.class, new ObjectId(id));
assertThat(storedView).isNotNull();
assertThat(storedView.getCode()).isEqualTo(CODE2);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testCreateViewExistingCode.
@Test
public void testCreateViewExistingCode() {
MorphiaView view = prepareView();
datastore.save(viewDao.databaseCollection(), view);
MorphiaView view2 = prepareView();
view2.setName(NAME2);
assertThatThrownBy(() -> viewDao.createView(view2)).isInstanceOf(DuplicateKeyException.class);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testCreateView.
@Test
public void testCreateView() {
MorphiaView view = prepareView();
String id = viewDao.createView(view).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
MorphiaView storedView = datastore.get(viewDao.databaseCollection(), MorphiaView.class, new ObjectId(id));
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);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDao method createView.
public View createView(final View view) {
MorphiaView morphiaView = new MorphiaView(view);
datastore.insert(databaseCollection(), morphiaView);
return morphiaView;
}
Aggregations