Search in sources :

Example 6 with LinkType

use of io.lumeer.api.model.LinkType in project engine by Lumeer.

the class MongoLinkTypeDaoTest method testUpdateLinkType.

@Test
public void testUpdateLinkType() {
    LinkType linkType = prepareLinkType();
    String id = linkTypeDao.createLinkType(linkType).getId();
    LinkType updateLinkedType = prepareLinkType();
    updateLinkedType.setName(NAME2);
    updateLinkedType.setCollectionIds(Arrays.asList(COLLECTION_ID3, COLLECTION_ID4));
    linkTypeDao.updateLinkType(id, updateLinkedType);
    LinkType storedLinkType = linkTypeDao.getLinkType(id);
    assertThat(storedLinkType).isNotNull();
    assertThat(storedLinkType.getName()).isEqualTo(NAME2);
    assertThat(storedLinkType.getAttributes()).isEqualTo(ATTRIBUTES);
    assertThat(storedLinkType.getCollectionIds()).containsOnlyElementsOf(Arrays.asList(COLLECTION_ID3, COLLECTION_ID4));
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 7 with LinkType

use of io.lumeer.api.model.LinkType in project engine by Lumeer.

the class MongoLinkTypeDaoTest method testDeleteLinkType.

@Test
public void testDeleteLinkType() {
    LinkType created = linkTypeDao.createLinkType(prepareLinkType());
    assertThat(created.getId()).isNotNull();
    linkTypeDao.deleteLinkType(created.getId());
    assertThatThrownBy(() -> linkTypeDao.getLinkType(created.getId())).isInstanceOf(StorageException.class);
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 8 with LinkType

use of io.lumeer.api.model.LinkType in project engine by Lumeer.

the class MongoLinkTypeDaoTest method testGetLinkType.

@Test
public void testGetLinkType() {
    String id = linkTypeDao.createLinkType(prepareLinkType()).getId();
    LinkType linkType = linkTypeDao.getLinkType(id);
    assertThat(linkType).isNotNull();
    assertThat(linkType.getId()).isEqualTo(id);
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 9 with LinkType

use of io.lumeer.api.model.LinkType in project engine by Lumeer.

the class MongoLinkTypeDaoTest method testUpdateLinkTypeExistingName.

@Test
public void testUpdateLinkTypeExistingName() {
    LinkType linkType = prepareLinkType();
    linkTypeDao.createLinkType(linkType);
    LinkType linkType2 = prepareLinkType();
    linkType2.setName(NAME2);
    String id = linkTypeDao.createLinkType(linkType2).getId();
    linkType2.setName(NAME);
    assertThat(linkTypeDao.updateLinkType(id, linkType2)).isNotNull();
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 10 with LinkType

use of io.lumeer.api.model.LinkType in project engine by Lumeer.

the class LinkInstanceFacadeIT method configureLinkInstances.

@Before
public void configureLinkInstances() {
    JsonOrganization organization = new JsonOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new JsonPermissions());
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
    JsonProject project = new JsonProject();
    project.setPermissions(new JsonPermissions());
    project.setCode(PROJECT_CODE);
    Project storedProject = projectDao.createProject(project);
    workspaceKeeper.setWorkspace(ORGANIZATION_CODE, PROJECT_CODE);
    collectionDao.setProject(storedProject);
    JsonPermissions collectionPermissions = new JsonPermissions();
    collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
    JsonCollection jsonCollection = new JsonCollection("col1", "col1", "icon", "color", collectionPermissions);
    jsonCollection.setDocumentsCount(0);
    String collection1 = collectionDao.createCollection(jsonCollection).getId();
    JsonCollection jsonCollection2 = new JsonCollection("col2", "col2", "icon", "color", collectionPermissions);
    jsonCollection.setDocumentsCount(0);
    String collection2 = collectionDao.createCollection(jsonCollection2).getId();
    LinkType linkType = new LinkType(null, NAME, Arrays.asList(collection1, collection2), ATTRIBUTES);
    linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
    LinkType linkType2 = new LinkType(null, NAME2, Arrays.asList(collection1, collection2), ATTRIBUTES);
    linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
    documentIdsColl1.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl1.add(createDocument(collection1).getId());
    }
    documentIdsColl2.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl2.add(createDocument(collection2).getId());
    }
}
Also used : JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) LinkType(io.lumeer.api.model.LinkType) JsonCollection(io.lumeer.api.dto.JsonCollection) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Aggregations

LinkType (io.lumeer.api.model.LinkType)26 Test (org.junit.Test)18 SearchQuery (io.lumeer.storage.api.query.SearchQuery)6 Response (javax.ws.rs.core.Response)5 ArrayList (java.util.ArrayList)4 Entity (javax.ws.rs.client.Entity)4 JsonQuery (io.lumeer.api.dto.JsonQuery)3 HashSet (java.util.HashSet)3 List (java.util.List)3 JsonCollection (io.lumeer.api.dto.JsonCollection)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)2 JsonPermission (io.lumeer.api.dto.JsonPermission)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)2 JsonProject (io.lumeer.api.dto.JsonProject)2 Collection (io.lumeer.api.model.Collection)2 Organization (io.lumeer.api.model.Organization)2 Project (io.lumeer.api.model.Project)2 User (io.lumeer.api.model.User)2 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)2 Before (org.junit.Before)2