Search in sources :

Example 1 with DataService

use of org.molgenis.data.DataService in project molgenis by molgenis.

the class FairControllerTest method beforeTest.

@BeforeMethod
public void beforeTest() {
    dataService = mock(DataService.class);
    entityModelWriter = mock(EntityModelWriter.class);
    controller = new FairController(dataService, entityModelWriter);
    mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter, new RdfConverter()).build();
}
Also used : FormHttpMessageConverter(org.springframework.http.converter.FormHttpMessageConverter) RdfConverter(org.molgenis.core.ui.converter.RdfConverter) DataService(org.molgenis.data.DataService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DataService

use of org.molgenis.data.DataService in project molgenis by molgenis.

the class RestServiceTest method setUpBeforeMethod.

@BeforeMethod
public void setUpBeforeMethod() {
    dataService = mock(DataService.class);
    idGenerator = mock(IdGenerator.class);
    FileStore fileStore = mock(FileStore.class);
    fileMetaFactory = mock(FileMetaFactory.class);
    entityManager = mock(EntityManager.class);
    servletUriComponentsBuilderFactory = mock(ServletUriComponentsBuilderFactory.class);
    this.restService = new RestService(dataService, idGenerator, fileStore, fileMetaFactory, entityManager, servletUriComponentsBuilderFactory);
}
Also used : FileStore(org.molgenis.data.file.FileStore) EntityManager(org.molgenis.data.EntityManager) FileMetaFactory(org.molgenis.data.file.model.FileMetaFactory) IdGenerator(org.molgenis.data.populate.IdGenerator) DataService(org.molgenis.data.DataService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with DataService

use of org.molgenis.data.DataService in project molgenis by molgenis.

the class OneToOneCategoryAlgorithmGeneratorTest method init.

@BeforeMethod
public void init() {
    dataService = Mockito.mock(DataService.class);
    categoryAlgorithmGenerator = new OneToOneCategoryAlgorithmGenerator(dataService);
    EntityType targetRefEntityType = createCategoricalRefEntityType("POTATO_REF");
    Entity targetEntity1 = new DynamicEntity(targetRefEntityType, of("code", 1, "label", "Almost daily + daily"));
    Entity targetEntity2 = new DynamicEntity(targetRefEntityType, of("code", 2, "label", "Several times a week"));
    Entity targetEntity3 = new DynamicEntity(targetRefEntityType, of("code", 3, "label", "About once a week"));
    Entity targetEntity4 = new DynamicEntity(targetRefEntityType, of("code", 4, "label", "Never + fewer than once a week"));
    Entity targetEntity5 = new DynamicEntity(targetRefEntityType, of("code", 9, "label", "missing"));
    targetAttribute = attrMetaFactory.create().setName("Current Consumption Frequency of Potatoes").setDataType(CATEGORICAL);
    targetAttribute.setRefEntity(targetRefEntityType);
    Mockito.when(dataService.findAll(targetRefEntityType.getId())).thenReturn(Stream.of(targetEntity1, targetEntity2, targetEntity3, targetEntity4, targetEntity5));
    targetEntityType = entityTypeFactory.create("target");
    targetEntityType.addAttribute(targetAttribute);
    EntityType sourceRefEntityType = createCategoricalRefEntityType("LifeLines_POTATO_REF");
    Entity sourceEntity1 = new DynamicEntity(targetRefEntityType, of("code", 1, "label", "Not this month"));
    Entity sourceEntity2 = new DynamicEntity(targetRefEntityType, of("code", 2, "label", "1 day per month"));
    Entity sourceEntity3 = new DynamicEntity(targetRefEntityType, of("code", 3, "label", "2-3 days per month"));
    Entity sourceEntity4 = new DynamicEntity(targetRefEntityType, of("code", 4, "label", "1 day per week"));
    Entity sourceEntity5 = new DynamicEntity(targetRefEntityType, of("code", 5, "label", "2-3 days per week"));
    Entity sourceEntity6 = new DynamicEntity(targetRefEntityType, of("code", 6, "label", "4-5 days per week"));
    Entity sourceEntity7 = new DynamicEntity(targetRefEntityType, of("code", 7, "label", "6-7 days per week"));
    Entity sourceEntity8 = new DynamicEntity(targetRefEntityType, of("code", 8, "label", "9 days per week"));
    sourceAttribute = attrMetaFactory.create().setName("MESHED_POTATO").setDataType(CATEGORICAL);
    sourceAttribute.setLabel("How often did you eat boiled or mashed potatoes (also in stew) in the past month? Baked potatoes are asked later");
    sourceAttribute.setRefEntity(sourceRefEntityType);
    Mockito.when(dataService.findAll(sourceRefEntityType.getId())).thenReturn(Stream.of(sourceEntity1, sourceEntity2, sourceEntity3, sourceEntity4, sourceEntity5, sourceEntity6, sourceEntity7, sourceEntity8));
    sourceEntityType = entityTypeFactory.create("source");
    sourceEntityType.addAttributes(Lists.newArrayList(sourceAttribute));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity) DataService(org.molgenis.data.DataService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with DataService

use of org.molgenis.data.DataService in project molgenis by molgenis.

the class EntityTypeValidatorTest method setUpBeforeMethod.

@SuppressWarnings("unchecked")
@BeforeMethod
public void setUpBeforeMethod() {
    dataService = mock(DataService.class);
    MetaDataService metaDataService = mock(MetaDataService.class);
    when(dataService.getMeta()).thenReturn(metaDataService);
    systemEntityTypeRegistry = mock(SystemEntityTypeRegistry.class);
    entityTypeValidator = new EntityTypeValidator(dataService, systemEntityTypeRegistry);
    String backendName = "backend";
    RepositoryCollection repoCollection = mock(RepositoryCollection.class);
    when(metaDataService.getBackend(backendName)).thenReturn(repoCollection);
    // valid entity meta
    entityType = when(mock(EntityType.class).getId()).thenReturn("entity").getMock();
    idAttr = when(mock(Attribute.class).getName()).thenReturn("idAttr").getMock();
    when(idAttr.getIdentifier()).thenReturn("#idAttr");
    when(idAttr.getDataType()).thenReturn(STRING);
    when(idAttr.isUnique()).thenReturn(true);
    when(idAttr.isNillable()).thenReturn(false);
    labelAttr = when(mock(Attribute.class).getName()).thenReturn("labelAttr").getMock();
    when(labelAttr.getIdentifier()).thenReturn("#labelAttr");
    when(labelAttr.getDataType()).thenReturn(STRING);
    entityQ = mock(Query.class);
    when(dataService.query(ENTITY_TYPE_META_DATA, EntityType.class)).thenReturn(entityQ);
    Query<EntityType> entityQ0 = mock(Query.class);
    Query<EntityType> entityQ1 = mock(Query.class);
    when(entityQ.eq(ATTRIBUTES, idAttr)).thenReturn(entityQ0);
    when(entityQ.eq(ATTRIBUTES, labelAttr)).thenReturn(entityQ1);
    when(entityQ0.findOne()).thenReturn(null);
    when(entityQ1.findOne()).thenReturn(null);
    attrQ = mock(Query.class);
    Query<Attribute> attrQ0 = mock(Query.class);
    Query<Attribute> attrQ1 = mock(Query.class);
    when(dataService.query(ATTRIBUTE_META_DATA, Attribute.class)).thenReturn(attrQ);
    when(attrQ.eq(CHILDREN, idAttr)).thenReturn(attrQ0);
    when(attrQ.eq(CHILDREN, labelAttr)).thenReturn(attrQ1);
    when(attrQ0.findOne()).thenReturn(null);
    when(attrQ1.findOne()).thenReturn(null);
    String packageName = "package";
    Package package_ = when(mock(Package.class).getId()).thenReturn(packageName).getMock();
    when(entityType.getPackage()).thenReturn(package_);
    String name = "name";
    String label = "label";
    when(entityType.getId()).thenReturn(packageName + PACKAGE_SEPARATOR + name);
    when(entityType.getLabel()).thenReturn(label);
    when(entityType.getOwnAllAttributes()).thenReturn(newArrayList(idAttr, labelAttr));
    when(entityType.getAllAttributes()).thenReturn(newArrayList(idAttr, labelAttr));
    when(entityType.getOwnIdAttribute()).thenReturn(idAttr);
    when(entityType.getOwnLabelAttribute()).thenReturn(labelAttr);
    when(entityType.getOwnLookupAttributes()).thenReturn(singletonList(labelAttr));
    when(entityType.isAbstract()).thenReturn(false);
    when(entityType.getExtends()).thenReturn(null);
    when(entityType.getBackend()).thenReturn(backendName);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) SystemEntityTypeRegistry(org.molgenis.data.meta.system.SystemEntityTypeRegistry) RepositoryCollection(org.molgenis.data.RepositoryCollection) MetaDataService(org.molgenis.data.meta.MetaDataService) Query(org.molgenis.data.Query) Attribute(org.molgenis.data.meta.model.Attribute) Package(org.molgenis.data.meta.model.Package) MetaDataService(org.molgenis.data.meta.MetaDataService) DataService(org.molgenis.data.DataService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with DataService

use of org.molgenis.data.DataService in project molgenis by molgenis.

the class GoogleAuthenticationProcessingFilterTest method setUp.

@BeforeMethod
public void setUp() {
    authenticationSettings = mock(AuthenticationSettings.class);
    UserDetailsService userDetailsService = mock(UserDetailsService.class);
    DataService dataService = mock(DataService.class);
    GooglePublicKeysManager googlePublicKeysManager = mock(GooglePublicKeysManager.class);
    UserFactory userFactory = mock(UserFactory.class);
    GroupMemberFactory groupMemberFactory = mock(GroupMemberFactory.class);
    googleAuthenticationProcessingFilter = new GoogleAuthenticationProcessingFilter(googlePublicKeysManager, dataService, userDetailsService, authenticationSettings, userFactory, groupMemberFactory);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
}
Also used : GooglePublicKeysManager(com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager) HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthenticationSettings(org.molgenis.security.settings.AuthenticationSettings) UserFactory(org.molgenis.data.security.auth.UserFactory) HttpServletResponse(javax.servlet.http.HttpServletResponse) UserDetailsService(org.molgenis.security.user.UserDetailsService) GroupMemberFactory(org.molgenis.data.security.auth.GroupMemberFactory) DataService(org.molgenis.data.DataService) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

DataService (org.molgenis.data.DataService)13 BeforeMethod (org.testng.annotations.BeforeMethod)9 EntityType (org.molgenis.data.meta.model.EntityType)4 Entity (org.molgenis.data.Entity)3 MetaDataService (org.molgenis.data.meta.MetaDataService)2 Attribute (org.molgenis.data.meta.model.Attribute)2 Package (org.molgenis.data.meta.model.Package)2 DynamicEntity (org.molgenis.data.support.DynamicEntity)2 GooglePublicKeysManager (com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager)1 Stream (java.util.stream.Stream)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DataSource (javax.sql.DataSource)1 RdfConverter (org.molgenis.core.ui.converter.RdfConverter)1 EntityManager (org.molgenis.data.EntityManager)1 Query (org.molgenis.data.Query)1 RepositoryCollection (org.molgenis.data.RepositoryCollection)1 FileStore (org.molgenis.data.file.FileStore)1 FileMetaFactory (org.molgenis.data.file.model.FileMetaFactory)1 SystemEntityTypeRegistry (org.molgenis.data.meta.system.SystemEntityTypeRegistry)1