Search in sources :

Example 96 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class RestControllerV2Test method testCopyEntity.

@Test
public void testCopyEntity() throws Exception {
    @SuppressWarnings("unchecked") Repository<Entity> repositoryToCopy = mock(Repository.class);
    Package pack = mocksForCopyEntitySuccess(repositoryToCopy);
    String content = "{newEntityName: 'newEntity'}";
    mockMvc.perform(post(HREF_COPY_ENTITY).content(content).contentType(APPLICATION_JSON)).andExpect(status().isCreated()).andExpect(content().contentType(APPLICATION_JSON_UTF8)).andExpect(content().string("\"org_molgenis_blah_newEntity\"")).andExpect(header().string("Location", "/api/v2/org_molgenis_blah_newEntity"));
    verify(repoCopier).copyRepository(repositoryToCopy, "newEntity", pack, "newEntity");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Package(org.molgenis.data.meta.model.Package)

Example 97 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class MappingServiceControllerTest method testScheduleMappingJobSystemPackage.

@Test
public void testScheduleMappingJobSystemPackage() throws Exception {
    when(mappingService.getMappingProject("mappingProjectId")).thenReturn(mappingProject);
    Package systemPackage = mock(Package.class);
    when(systemPackage.getId()).thenReturn("sys");
    when(metaDataService.getPackage("sys")).thenReturn(systemPackage);
    mockMvc.perform(post(URI + "/map").param("mappingProjectId", "mappingProjectId").param("targetEntityTypeId", "targetEntityTypeId").param("label", "label").param("package", "sys").accept("text/plain")).andExpect(status().isBadRequest()).andExpect(content().contentType("text/plain")).andExpect(content().string("Package [sys] is a system package."));
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 98 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class OntologyTagServiceTest method testGetTagsForPackage.

@Test
public void testGetTagsForPackage() {
    Package p = packageFactory.create("test", "desc");
    Package pack = packageFactory.create();
    pack.setTags(singletonList(chromosomeNameTagEntity));
    when(ontologyService.getOntology("http://edamontology.org")).thenReturn(EDAM_ONTOLOGY);
    when(ontologyService.getOntologyTerm("http://edamontology.org/data_0987")).thenReturn(CHROMOSOME_NAME_ONTOLOGY_TERM);
    when(dataService.findOneById(PACKAGE, "test")).thenReturn(pack);
    assertEquals(ontologyTagService.getTagsForPackage(p), singletonList(new SemanticTag<>("1234", p, Relation.forIRI("http://molgenis.org/biobankconnect/instanceOf"), OntologyTerm.create("http://edamontology.org/data_0987", "Chromosome name", "Name of a chromosome."), Ontology.create("EDAM", "http://edamontology.org", "The EDAM ontology."))));
}
Also used : Package(org.molgenis.data.meta.model.Package) SemanticTag(org.molgenis.data.semantic.SemanticTag) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

Package (org.molgenis.data.meta.model.Package)98 Test (org.testng.annotations.Test)70 EntityType (org.molgenis.data.meta.model.EntityType)22 Stream (java.util.stream.Stream)20 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)13 Attribute (org.molgenis.data.meta.model.Attribute)11 DefaultPackage (org.molgenis.data.meta.DefaultPackage)10 MolgenisValidationException (org.molgenis.data.validation.MolgenisValidationException)10 Objects.requireNonNull (java.util.Objects.requireNonNull)6 L10nString (org.molgenis.data.i18n.model.L10nString)6 PackageIdentity (org.molgenis.data.security.PackageIdentity)6 Collectors.toList (java.util.stream.Collectors.toList)5 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)5 DataService (org.molgenis.data.DataService)5 QueryImpl (org.molgenis.data.support.QueryImpl)5 RepositoryCollection (org.molgenis.data.RepositoryCollection)4 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 java.util (java.util)3 Collections.singletonList (java.util.Collections.singletonList)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3