@Test public void countNcloc_and_exclude_project() { OrganizationDto organization = db.organizations().insert(); MetricDto ncloc = db.measures().insertMetric(m -> m.setKey("ncloc").setValueType(INT.toString())); ComponentDto simpleProject = db.components().insertMainBranch(organization); db.measures().insertLiveMeasure(simpleProject, ncloc, m -> m.setValue(10d)); ComponentDto projectWithBiggerLongLivingBranch = db.components().insertMainBranch(organization); ComponentDto bigLongLivingBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.LONG)); db.measures().insertLiveMeasure(projectWithBiggerLongLivingBranch, ncloc, m -> m.setValue(100d)); db.measures().insertLiveMeasure(bigLongLivingBranch, ncloc, m -> m.setValue(200d)); ComponentDto projectToExclude = db.components().insertMainBranch(organization); ComponentDto projectToExcludeBranch = db.components().insertProjectBranch(projectToExclude, b -> b.setBranchType(BranchType.LONG)); db.measures().insertLiveMeasure(projectToExclude, ncloc, m -> m.setValue(300d)); db.measures().insertLiveMeasure(projectToExcludeBranch, ncloc, m -> m.setValue(400d)); SumNclocDbQuery query = SumNclocDbQuery.builder() .setOrganizationUuid(organization.getUuid()) .setProjectUuidToExclude(projectToExclude.uuid()) .setOnlyPrivateProjects(false) .build(); long result = underTest.sumNclocOfBiggestLongLivingBranch(db.getSession(), query); assertThat(result).isEqualTo(10L + 200L); }