@Test public void shouldBeExcluded() { File file = new File("org/foo/ExcludedBar.java"); assertThat(index.index(file), is(false)); assertThat(index.isIndexed(file, true), is(true)); assertThat(index.isIndexed(file, false), is(false)); assertThat(index.isExcluded(file), is(true)); }
@Test public void shouldNotIndexResourceIfParentNotIndexed() { Directory directory = new Directory("org/other"); File file = new File("org/foo/Bar.java"); assertThat(index.index(file, directory), is(false)); File fileRef = new File("org/foo/Bar.java"); assertThat(index.isIndexed(directory, true), is(false)); assertThat(index.isIndexed(fileRef, true), is(false)); assertThat(index.isExcluded(fileRef), is(false)); assertThat(index.getChildren(fileRef).size(), is(0)); assertThat(index.getParent(fileRef), nullValue()); }
@Test public void shouldIndexResourceWhenAddingMeasure() { Resource dir = new Directory("org/foo"); index.addMeasure(dir, new Measure("ncloc").setValue(50.0)); assertThat(index.isIndexed(dir, true), is(true)); assertThat(index.getMeasures(dir, MeasuresFilters.metric("ncloc")).getIntValue(), is(50)); }
/** Only a warning is logged when index is locked. */ @Test public void shouldIndexEvenIfLocked() { lock.lock(); Directory dir = new Directory("org/foo"); assertThat(index.index(dir), is(true)); assertThat(index.isIndexed(dir, true), is(true)); }
@Test public void shouldIndexLibraryOutsideProjectTree() { Library lib = new Library("junit", "4.8"); assertThat(index.index(lib), is(true)); Library reference = new Library("junit", "4.8"); assertThat(index.getResource(reference).getQualifier(), is(Qualifiers.LIBRARY)); assertThat(index.isIndexed(reference, true), is(true)); assertThat(index.isExcluded(reference), is(false)); }
@Test public void shouldIndexParentOfDeprecatedFiles() { File file = new File("org/foo/Bar.java"); assertThat(index.index(file), is(true)); Directory reference = new Directory("org/foo"); assertThat(index.getResource(reference).getName(), is("org/foo")); assertThat(index.isIndexed(reference, true), is(true)); assertThat(index.isExcluded(reference), is(false)); assertThat(index.getChildren(reference).size(), is(1)); assertThat(index.getParent(reference), is(Project.class)); }
@Test public void shouldIndexTreeOfResources() { Directory directory = new Directory("org/foo"); File file = new File("org/foo/Bar.java"); file.setLanguage(Java.INSTANCE); assertThat(index.index(directory), is(true)); assertThat(index.index(file, directory), is(true)); File fileRef = new File("org/foo/Bar.java"); assertThat(index.getResource(fileRef).getKey(), is("org/foo/Bar.java")); assertThat(index.getResource(fileRef).getLanguage(), is((Language) Java.INSTANCE)); assertThat(index.isIndexed(fileRef, true), is(true)); assertThat(index.isExcluded(fileRef), is(false)); assertThat(index.getChildren(fileRef).size(), is(0)); assertThat(index.getParent(fileRef), is(Directory.class)); }