@Test
  public void exists() {
    boolean exists = container.exists(location);
    assertFalse(exists);

    when(workspace.hasResource(location)).thenReturn(true);

    exists = container.exists(location);
    assertTrue(exists);
  }
  @Test
  public void whenFindingMemberThatDoNotExsitsShouldReturnNull() {
    IResource expectedMember = Mockito.mock(IResource.class);

    when(workspace.newResource(any(IPath.class))).thenReturn(expectedMember);
    when(workspace.newResource(any(IPath.class))).thenReturn(null);

    IResource actualMember = container.findMember(path);

    assertNull(actualMember);

    actualMember = container.findMember(path);

    assertNull(actualMember);
  }
  @Test
  public void getEntity() {
    IEntity actualEntity = container.getEntity();

    assertNotNull(actualEntity);
    assertEquals(expectedEntity, actualEntity);
  }
  @Test
  public void emptyMembers() throws Exception {
    IResource[] members = container.members();

    assertNotNull(members);
    assertEquals(0, members.length);
  }
 @Test
 public void whenUsingUnsupportedMethodExceptionShouldBeThrown() throws Exception {
   try {
     container.createFilter(0, null, 0, null);
     fail(
         "container.createFilter(int, FileInfoMatcherDescription, int, IProgressMonitor) should be unsupported");
   } catch (UnsupportedOperationException e) {
     // Expected
   }
   try {
     container.removeFilter(null, 0, null);
     fail(
         "container.removeFilter(IResourceFilterDescription, int, IProgressMonitor) should be unsupported");
   } catch (UnsupportedOperationException e) {
     // Expected
   }
 }
  @Test
  public void getFile() {
    when(path.segmentCount()).thenReturn(2);

    IFile file = container.getFile(path);

    assertNotNull(file);
  }
  @Test
  public void getFolder() {
    when(path.segmentCount()).thenReturn(2);

    IFolder folder = container.getFolder(path);

    assertNotNull(folder);
  }
  @Test
  public void findMemberByString() {
    IResource expectedMember = Mockito.mock(IResource.class);

    when(workspace.newResource(any(IPath.class))).thenReturn(expectedMember);
    when(expectedMember.exists()).thenReturn(true);

    IResource actualMember = container.findMember("test");

    assertNotNull(actualMember);
    assertEquals(expectedMember, actualMember);
  }
  @Test
  public void members() throws Exception {
    List<String> collectionsNames = new ArrayList<String>();
    collectionsNames.add("member1");
    collectionsNames.add("member2");

    when(expectedEntity.getCollectionsNames()).thenReturn(collectionsNames);

    IResource[] members = container.members(true);

    assertNotNull(members);
    assertEquals(2, members.length);
  }
 @Test(expected = IllegalArgumentException.class)
 public void getFolderWithPathWithLessThanTwoSegmentsShouldThrowException() {
   container.getFolder(path);
 }
 @Test
 public void getFilters() throws Exception {
   IResourceFilterDescription[] filterDescription = container.getFilters();
   assertNotNull(filterDescription);
 }
  @Test(expected = CoreException.class)
  public void whenErrorOccursDuringExtractingMembersCoreExceptionShouldBeThrows() throws Exception {
    doThrow(new IOException()).when(expectedEntity).getCollectionsNames();

    container.members(true);
  }