@Test
public void createPredicatesForTransactionEntity_shouldNotIncludeTransactionEntityPredicateWhenTransactionEntityIdIsNotProvided() throws Exception {
Set<Predicate<IdentityProviderConfigEntityData>> predicates = idpPredicateFactory.createPredicatesForTransactionEntity(null);
Predicate<Predicate> findEnabled = input -> {
if(!(input instanceof OnboardingForTransactionEntityPredicate)){
return false;
}
return ((OnboardingForTransactionEntityPredicate)input).getTransactionEntity().equals(TRANSACTION_ENTITY);
};
assertThat(Collections2.filter(predicates, findEnabled)).isEmpty();
}
java类com.google.common.collect.Collections2的实例源码
IdpPredicateFactoryTest.java 文件源码
项目:verify-hub
阅读 23
收藏 0
点赞 0
评论 0
Utils.java 文件源码
项目:burp-vulners-scanner
阅读 24
收藏 0
点赞 0
评论 0
public static Double getMaxScore(Set<Vulnerability> vulnerabilities) {
if (vulnerabilities.size() <= 0) {
return null;
}
Collection<Double> scores = Collections2.transform(
vulnerabilities, new Function<Vulnerability, Double>() {
@Override
public Double apply(Vulnerability vulnerability) {
return vulnerability.getCvssScore();
}
}
);
return Ordering.natural().max(scores);
}
ViewChanges.java 文件源码
项目:morf
阅读 28
收藏 0
点赞 0
评论 0
/**
* Correct case of names with respect to all the views we know about.
*
* @return equivalent collection with names case-corrected where possible.
*/
private Collection<String> correctCase(Collection<String> names) {
return newHashSet(Collections2.transform(names, new Function<String, String>() {
@Override public String apply(String name) {
for (View view: allViews) {
if (view.getName().equalsIgnoreCase(name)) {
return view.getName();
}
}
return name;
}
}));
}
StacksService.java 文件源码
项目:redirector
阅读 17
收藏 0
点赞 0
评论 0
private Collection<XreStackPath> getStackPathsForServiceAndFlavor(final String serviceName, final String flavor) {
return Collections2.filter(stacksDAO.getAllStackPaths(), new Predicate<XreStackPath>() {
@Override
public boolean apply(XreStackPath input) {
return input.getServiceName().equals(serviceName) && input.getFlavor().equals(flavor);
}
});
}
MesosStateService.java 文件源码
项目:elastic-job-cloud
阅读 15
收藏 0
点赞 0
评论 0
/**
* 查找执行器信息.
*
* @param appName 作业云配置App的名字
* @return 执行器信息
* @throws JSONException 解析JSON格式异常
*/
public Collection<ExecutorStateInfo> executors(final String appName) throws JSONException {
return Collections2.transform(findExecutors(fetch(stateUrl).getJSONArray("frameworks"), appName), new Function<JSONObject, ExecutorStateInfo>() {
@Override
public ExecutorStateInfo apply(final JSONObject input) {
try {
return ExecutorStateInfo.builder().id(getExecutorId(input)).slaveId(input.getString("slave_id")).build();
} catch (final JSONException ex) {
throw new RuntimeException(ex);
}
}
});
}
ReadyService.java 文件源码
项目:elastic-job-cloud
阅读 15
收藏 0
点赞 0
评论 0
/**
* 从待执行队列中获取所有有资格执行的作业上下文.
*
* @param ineligibleJobContexts 无资格执行的作业上下文
* @return 有资格执行的作业上下文集合
*/
public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) {
if (!regCenter.isExisted(ReadyNode.ROOT)) {
return Collections.emptyList();
}
Collection<String> ineligibleJobNames = Collections2.transform(ineligibleJobContexts, new Function<JobContext, String>() {
@Override
public String apply(final JobContext input) {
return input.getJobConfig().getJobName();
}
});
List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT);
List<JobContext> result = new ArrayList<>(jobNames.size());
for (String each : jobNames) {
if (ineligibleJobNames.contains(each)) {
continue;
}
Optional<CloudJobConfiguration> jobConfig = configService.load(each);
if (!jobConfig.isPresent()) {
regCenter.remove(ReadyNode.getReadyJobNodePath(each));
continue;
}
if (!runningService.isJobRunning(each)) {
result.add(JobContext.from(jobConfig.get(), ExecutionType.READY));
}
}
return result;
}
MinijaxSwaggerTest.java 文件源码
项目:minijax
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void returnProperBeanParamWithDefaultParameterExtension() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("testRoute", BaseBean.class, ChildBean.class, RefBean.class, EnumBean.class, Integer.class);
final List<Pair<Type, Annotation[]>> parameters = getParameters(method.getGenericParameterTypes(), method.getParameterAnnotations());
for (final Pair<Type, Annotation[]> parameter : parameters) {
final Type parameterType = parameter.first();
final List<Parameter> swaggerParams = new DefaultParameterExtension().extractParameters(Arrays.asList(parameter.second()),
parameterType, new HashSet<Type>(), SwaggerExtensions.chain());
// Ensure proper number of parameters returned
if (parameterType.equals(BaseBean.class)) {
assertEquals(2, swaggerParams.size());
} else if (parameterType.equals(ChildBean.class)) {
assertEquals(5, swaggerParams.size());
} else if (parameterType.equals(RefBean.class)) {
assertEquals(5, swaggerParams.size());
} else if (parameterType.equals(EnumBean.class)) {
assertEquals(1, swaggerParams.size());
final HeaderParameter enumParam = (HeaderParameter) swaggerParams.get(0);
assertEquals("string", enumParam.getType());
final List<String> enumValues = new ArrayList<>(Collections2.transform(Arrays.asList(TestEnum.values()), Functions.toStringFunction()));
assertEquals(enumValues, enumParam.getEnum());
} else if (parameterType.equals(Integer.class)) {
assertEquals(0, swaggerParams.size());
} else {
fail(String.format("Parameter of type %s was not expected", parameterType));
}
// Ensure the proper parameter type and name is returned (The rest is handled by pre-existing logic)
for (final Parameter param : swaggerParams) {
assertEquals(param.getClass().getSimpleName().replace("eter", ""), param.getName());
}
}
}
PGMMapEnvironment.java 文件源码
项目:ProjectAres
阅读 15
收藏 0
点赞 0
评论 0
@Override
public Set<Entry<String, Boolean>> entrySet() {
return ImmutableSet.copyOf(Collections2.transform(
keySet(),
key -> Maps.immutableEntry(key, get(key))
));
}
TouchableGoal.java 文件源码
项目:ProjectAres
阅读 14
收藏 0
点赞 0
评论 0
@Override
public Collection<? extends MatchDoc.TouchableGoal.Proximity> proximities() {
return Collections2.transform(
getMatch().getCompetitors(),
new Function<Competitor, MatchDoc.TouchableGoal.Proximity>() {
@Override
public MatchDoc.TouchableGoal.Proximity apply(Competitor competitor) {
return new Proximity(competitor);
}
}
);
}
MatchAnnouncer.java 文件源码
项目:ProjectAres
阅读 15
收藏 0
点赞 0
评论 0
public void sendWelcomeMessage(MatchPlayer viewer) {
MapInfo mapInfo = viewer.getMatch().getMapInfo();
final Component name = new Component(mapInfo.name, ChatColor.BOLD, ChatColor.AQUA);
final Component objective = new Component(mapInfo.objective, ChatColor.BLUE, ChatColor.ITALIC);
if(Config.Broadcast.title()) {
viewer.getBukkit().showTitle(name, objective, TITLE_FADE, TITLE_STAY, TITLE_FADE);
}
viewer.sendMessage(new HeaderComponent(ChatColor.WHITE, CHAT_WIDTH, name));
for(BaseComponent line : Components.wordWrap(objective, CHAT_WIDTH)) {
viewer.sendMessage(line);
}
final List<Contributor> authors = mapInfo.getNamedAuthors();
if(!authors.isEmpty()) {
viewer.sendMessage(
new Component(" ", ChatColor.DARK_GRAY).extra(
new TranslatableComponent(
"broadcast.welcomeMessage.createdBy",
new ListComponent(Lists.transform(authors, author -> author.getStyledName(NameStyle.MAPMAKER)))
)
)
);
}
final MutationMatchModule mmm = viewer.getMatch().getMatchModule(MutationMatchModule.class);
if(mmm != null && mmm.getActiveMutations().size() > 0) {
viewer.sendMessage(
new Component(" ", ChatColor.DARK_GRAY).extra(
new TranslatableComponent("broadcast.welcomeMessage.mutations",
new ListComponent(Collections2.transform(mmm.getActiveMutations(), Mutation.toComponent(ChatColor.GREEN)))
)
)
);
}
viewer.sendMessage(new HeaderComponent(ChatColor.WHITE, CHAT_WIDTH));
}