use of com.google.common.collect.Multimap in project sonarqube by SonarSource.
the class ActiveRuleIndex method getStatsByProfileKeys.
public Map<String, Multimap<String, FacetValue>> getStatsByProfileKeys(List<String> keys) {
SearchRequestBuilder request = getClient().prepareSearch(INDEX_TYPE_RULE.getIndex()).setQuery(QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(FIELD_ACTIVE_RULE_PROFILE_KEY, keys)).filter(QueryBuilders.boolQuery().mustNot(QueryBuilders.hasParentQuery(INDEX_TYPE_RULE.getType(), QueryBuilders.termQuery(FIELD_RULE_STATUS, RuleStatus.REMOVED.name()))))).addAggregation(AggregationBuilders.terms(FIELD_ACTIVE_RULE_PROFILE_KEY).field(RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_KEY).size(0).subAggregation(AggregationBuilders.terms(FIELD_ACTIVE_RULE_INHERITANCE).field(RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE)).subAggregation(AggregationBuilders.terms(FIELD_ACTIVE_RULE_SEVERITY).field(RuleIndexDefinition.FIELD_ACTIVE_RULE_SEVERITY)).subAggregation(AggregationBuilders.count(COUNT_ACTIVE_RULES))).setSize(0);
SearchResponse response = request.get();
Map<String, Multimap<String, FacetValue>> stats = new HashMap<>();
Aggregation aggregation = response.getAggregations().get(FIELD_ACTIVE_RULE_PROFILE_KEY);
for (Terms.Bucket value : ((Terms) aggregation).getBuckets()) {
stats.put(value.getKeyAsString(), processAggregations(value.getAggregations()));
}
return stats;
}
use of com.google.common.collect.Multimap in project sonarqube by SonarSource.
the class ActiveRuleIndexTest method stats_for_all.
@Test
public void stats_for_all() {
indexRules(newDoc(RULE_KEY_1), newDoc(RULE_KEY_2));
ActiveRuleKey activeRuleKey1 = ActiveRuleKey.of(QUALITY_PROFILE_KEY1, RULE_KEY_1);
ActiveRuleKey activeRuleKey2 = ActiveRuleKey.of(QUALITY_PROFILE_KEY1, RULE_KEY_2);
indexActiveRules(ActiveRuleDocTesting.newDoc(activeRuleKey1).setSeverity(BLOCKER), ActiveRuleDocTesting.newDoc(activeRuleKey2).setSeverity(MINOR), // Profile 2 is a child a profile 1
ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_1)).setSeverity(MAJOR).setInheritance(INHERITED.name()), ActiveRuleDocTesting.newDoc(ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_2)).setSeverity(BLOCKER).setInheritance(OVERRIDES.name()));
// 0. Test base case
assertThat(tester.countDocuments(INDEX_TYPE_ACTIVE_RULE)).isEqualTo(4);
// 1. Assert by term aggregation;
Map<String, Multimap<String, FacetValue>> stats = index.getStatsByProfileKeys(ImmutableList.of(QUALITY_PROFILE_KEY1, QUALITY_PROFILE_KEY2));
assertThat(stats).hasSize(2);
}
use of com.google.common.collect.Multimap in project sonarqube by SonarSource.
the class UserUpdaterTest method not_associate_default_group_when_updating_user_if_already_existing.
@Test
public void not_associate_default_group_when_updating_user_if_already_existing() {
UserDto user = db.users().insertUser(newLocalUser(DEFAULT_LOGIN, "Marius", "marius@email.com"));
GroupDto defaultGroup = createDefaultGroup();
db.users().insertMember(defaultGroup, user);
// User is already associate to the default group
Multimap<String, String> groups = dbClient.groupMembershipDao().selectGroupsByLogins(session, asList(DEFAULT_LOGIN));
assertThat(groups.get(DEFAULT_LOGIN).stream().anyMatch(g -> g.equals(DEFAULT_GROUP))).as("Current user groups : %s", groups.get(DEFAULT_GROUP)).isTrue();
underTest.update(session, UpdateUser.create(DEFAULT_LOGIN).setName("Marius2").setEmail("marius2@mail.com").setPassword("password2").setScmAccounts(newArrayList("ma2")));
session.commit();
// Nothing as changed
groups = dbClient.groupMembershipDao().selectGroupsByLogins(session, asList(DEFAULT_LOGIN));
assertThat(groups.get(DEFAULT_LOGIN).stream().anyMatch(g -> g.equals(DEFAULT_GROUP))).isTrue();
}
use of com.google.common.collect.Multimap in project atlas by alibaba.
the class NativeSoUtils method getAbiSoFiles.
/**
* 校验指定abi下的so文件的目录
*
* @param supportAbis
* @param removeSoFiles
* @param dirs
* @return
*/
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles, List<File> dirs) {
Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
for (File dir : dirs) {
Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
for (File file : files) {
File parentFolder = file.getParentFile();
String parentName = parentFolder.getName();
String shortName = getSoShortName(file);
Multimap<String, File> maps = result.get(parentName);
if (null == maps) {
maps = HashMultimap.create(10, 3);
}
maps.put(shortName, file);
result.put(parentName, maps);
}
}
return result;
}
use of com.google.common.collect.Multimap in project Minechem by iopleke.
the class AugmentSharp method getAttributeModifiers.
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack, int level) {
Multimap multimap = super.getAttributeModifiers(stack, level);
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(AugmentedItem.itemUUID, "Weapon modifier", (double) level, 0));
return multimap;
}
Aggregations