コード例 #1
0
 @Test
 public void testAddWithIdentifier() {
   MappingProject mappingProject = new MappingProject("My first mapping project", owner);
   mappingProject.setIdentifier("mappingProjectID");
   try {
     mappingProjectRepositoryImpl.add(mappingProject);
   } catch (MolgenisDataException mde) {
     assertEquals(mde.getMessage(), "MappingProject already exists");
   }
 }
コード例 #2
0
 @Test
 public void testUpdateUnknown() {
   mappingProject.setIdentifier("mappingProjectID");
   when(dataService.findOne(ENTITY_NAME, "mappingProjectID")).thenReturn(null);
   try {
     mappingProjectRepositoryImpl.update(mappingProject);
     fail("Expected exception");
   } catch (MolgenisDataException expected) {
     assertEquals(expected.getMessage(), "MappingProject does not exist");
   }
 }
コード例 #3
0
 @Test
 public void testFindAll() {
   Query q = new QueryImpl();
   q.eq(OWNER, "flup");
   when(dataService.findAll(ENTITY_NAME)).thenReturn(Stream.of(mappingProjectEntity));
   when(userService.getUser("flup")).thenReturn(owner);
   when(mappingTargetRepository.toMappingTargets(mappingTargetEntities))
       .thenReturn(asList(mappingTarget1, mappingTarget2));
   List<MappingProject> result = mappingProjectRepositoryImpl.getAllMappingProjects();
   mappingProject.setIdentifier("mappingProjectID");
   assertEquals(result, asList(mappingProject));
 }
コード例 #4
0
  @Test
  public void testAdd() {
    when(idGenerator.generateId()).thenReturn("mappingProjectID");
    when(mappingTargetRepository.upsert(asList(mappingTarget1, mappingTarget2)))
        .thenReturn(mappingTargetEntities);

    mappingProjectRepositoryImpl.add(mappingProject);

    Mockito.verify(dataService).add(ENTITY_NAME, mappingProjectEntity);
    assertNull(mappingTarget1.getIdentifier());
    assertNull(mappingTarget2.getIdentifier());
  }
コード例 #5
0
 @Test
 public void testDelete() {
   mappingProjectRepositoryImpl.delete("abc");
   verify(dataService).delete(ENTITY_NAME, "abc");
 }