@VisibleForTesting static Map<String, String> toMap(List<Setting> settingsList) { Map<String, String> result = new LinkedHashMap<>(); for (Setting s : settingsList) { if (!s.getInherited()) { switch (s.getValueOneOfCase()) { case VALUE: result.put(s.getKey(), s.getValue()); break; case VALUES: result.put(s.getKey(), s.getValues().getValuesList().stream().map(StringEscapeUtils::escapeCsv).collect(Collectors.joining(","))); break; case FIELDVALUES: convertPropertySetToProps(result, s); break; default: throw new IllegalStateException("Unknow property value for " + s.getKey()); } } } return result; }
public WorkflowDef fromProto(WorkflowDefPb.WorkflowDef from) { WorkflowDef to = new WorkflowDef(); to.setName( from.getName() ); to.setDescription( from.getDescription() ); to.setVersion( from.getVersion() ); to.setTasks( from.getTasksList().stream().map(this::fromProto).collect(Collectors.toCollection(ArrayList::new)) ); to.setInputParameters( from.getInputParametersList().stream().collect(Collectors.toCollection(ArrayList::new)) ); Map<String, Object> outputParametersMap = new HashMap<String, Object>(); for (Map.Entry<String, Value> pair : from.getOutputParametersMap().entrySet()) { outputParametersMap.put( pair.getKey(), fromProto( pair.getValue() ) ); } to.setOutputParameters(outputParametersMap); to.setFailureWorkflow( from.getFailureWorkflow() ); to.setSchemaVersion( from.getSchemaVersion() ); to.setRestartable( from.getRestartable() ); to.setWorkflowStatusListenerEnabled( from.getWorkflowStatusListenerEnabled() ); return to; }
public TaskDef fromProto(TaskDefPb.TaskDef from) { TaskDef to = new TaskDef(); to.setName( from.getName() ); to.setDescription( from.getDescription() ); to.setRetryCount( from.getRetryCount() ); to.setTimeoutSeconds( from.getTimeoutSeconds() ); to.setInputKeys( from.getInputKeysList().stream().collect(Collectors.toCollection(ArrayList::new)) ); to.setOutputKeys( from.getOutputKeysList().stream().collect(Collectors.toCollection(ArrayList::new)) ); to.setTimeoutPolicy( fromProto( from.getTimeoutPolicy() ) ); to.setRetryLogic( fromProto( from.getRetryLogic() ) ); to.setRetryDelaySeconds( from.getRetryDelaySeconds() ); to.setResponseTimeoutSeconds( from.getResponseTimeoutSeconds() ); to.setConcurrentExecLimit( from.getConcurrentExecLimit() ); Map<String, Object> inputTemplateMap = new HashMap<String, Object>(); for (Map.Entry<String, Value> pair : from.getInputTemplateMap().entrySet()) { inputTemplateMap.put( pair.getKey(), fromProto( pair.getValue() ) ); } to.setInputTemplate(inputTemplateMap); to.setRateLimitPerFrequency( from.getRateLimitPerFrequency() ); to.setRateLimitFrequencyInSeconds( from.getRateLimitFrequencyInSeconds() ); return to; }
to.setSubWorkflowParam( fromProto( from.getSubWorkflowParam() ) ); to.setJoinOn( from.getJoinOnList().stream().collect(Collectors.toCollection(ArrayList::new)) ); to.setSink( from.getSink() ); to.setOptional( from.getOptional() );
to.setEvent( from.getEvent() ); to.setTaskToDomain( from.getTaskToDomainMap() ); to.setFailedReferenceTaskNames( from.getFailedReferenceTaskNamesList().stream().collect(Collectors.toCollection(HashSet::new)) ); if (from.hasWorkflowDefinition()) { to.setWorkflowDefinition( fromProto( from.getWorkflowDefinition() ) );
@Test public void should_return_specified_fields() { RuleDefinitionDto rule = db.rules().insert(r1 -> r1.setLanguage("java")); indexRules(); checkField(rule, "repo", Rule::getRepo, rule.getRepositoryKey()); checkField(rule, "name", Rule::getName, rule.getName()); checkField(rule, "severity", Rule::getSeverity, rule.getSeverityString()); checkField(rule, "status", r -> r.getStatus().toString(), rule.getStatus().toString()); checkField(rule, "internalKey", Rule::getInternalKey, rule.getConfigKey()); checkField(rule, "isTemplate", Rule::getIsTemplate, rule.isTemplate()); checkField(rule, "sysTags", r -> r.getSysTags().getSysTagsList().stream().collect(Collectors.joining(",")), rule.getSystemTags().stream().collect(Collectors.joining(","))); checkField(rule, "lang", Rule::getLang, rule.getLanguage()); checkField(rule, "langName", Rule::getLangName, languages.get(rule.getLanguage()).getName()); checkField(rule, "gapDescription", Rule::getGapDescription, rule.getGapDescription()); // to be continued... }
public LanguageMatcher(DeviceSpec deviceSpec) { super(deviceSpec); this.deviceLanguages = deviceSpec .getSupportedLocalesList() .stream() .map(ResourcesUtils::convertLocaleToLanguage) .collect(toImmutableSet()); }
ApkSerializerHelper( Aapt2Command aapt2Command, Optional<SigningConfiguration> signingConfig, Version bundleVersion, Compression compression) { this.aapt2Command = aapt2Command; this.bundleVersion = bundleVersion; this.signingConfig = signingConfig; // Using the default filesystem will work on Windows because the "/" of the glob are swapped // with "\" when the PathMatcher is constructed and we then use a FileSystem's Path when // comparing which will thus also use the "\" separator. FileSystem fileSystem = FileSystems.getDefault(); this.uncompressedPathMatchers = compression.getUncompressedGlobList().stream() .map(glob -> "glob:" + glob) .map(fileSystem::getPathMatcher) .collect(toImmutableList()); }
private ImmutableSet<AbiAlias> deviceAbiAliases() { return getDeviceSpec().getSupportedAbisList().stream() .map( abi -> AbiName.fromPlatformName(abi) .orElseThrow( () -> ValidationException.builder() .withMessage("Unrecognized ABI '%s' in device spec.", abi) .build()) .toProto()) .collect(toImmutableSet()); } }
@Override protected void checkDeviceCompatibleInternal(AbiTargeting targeting) { if (targeting.equals(AbiTargeting.getDefaultInstance())) { return; } ImmutableSet<String> valuesAndAlternativesSet = Streams.concat( targeting.getValueList().stream() .map(Abi::getAlias) .map(AbiName::fromProto) .map(AbiName::getPlatformName), targeting.getAlternativesList().stream() .map(Abi::getAlias) .map(AbiName::fromProto) .map(AbiName::getPlatformName)) .collect(toImmutableSet()); ImmutableSet<String> deviceAbis = getDeviceSpec().getSupportedAbisList().stream().collect(toImmutableSet()); SetView<String> intersection = Sets.intersection(valuesAndAlternativesSet, deviceAbis); if (intersection.isEmpty()) { throw CommandExecutionException.builder() .withMessage( "The app doesn't support ABI architectures of the device. " + "Device ABIs: %s, app ABIs: %s.", getDeviceSpec().getSupportedAbisList(), valuesAndAlternativesSet) .build(); } }
() -> LINE_JOINER.join( deviceSpec.getDeviceFeaturesList().stream() .map(feature -> "feature:" + feature) .collect(toImmutableList()))); "config: mcc234-mnc15-" + DASH_JOINER.join( deviceSpec.getSupportedLocalesList().stream() .map(FakeDevice::convertLocaleToResourceString) .collect(toImmutableList())))));
private Response createResponse(DiscoveryRequest request, Map<String, ? extends Message> resources, String version) { Collection<? extends Message> filtered = request.getResourceNamesList().isEmpty() ? resources.values() : request.getResourceNamesList().stream() .map(resources::get) .filter(Objects::nonNull) .collect(Collectors.toList()); return Response.create(request, filtered, version); }
static ConceptList conceptList(AnswerProto.ConceptList res) { return new ConceptList(res.getList().getIdsList().stream().map(ConceptId::of).collect(toList())); }
static ConceptSet conceptSet(AnswerProto.ConceptSet res) { return new ConceptSet(res.getSet().getIdsList().stream().map(ConceptId::of).collect(toSet())); }
private boolean parentHasChild(UnitConfig parent, UnitConfig child) { return parent.getLocationConfig().getChildIdList().stream().anyMatch((children) -> (children.equals(child.getId()))); } }
@Override public List<UnitConfig> getAuthorizationGroupConfigsbyUserConfig(UnitConfig userConfig) throws CouldNotPerformException { validateData(); List<UnitConfig> groupConfigs = new ArrayList<>(); for (UnitConfig group : getAuthorizationGroupConfigs()) { group.getAuthorizationGroupConfig().getMemberIdList().stream().filter((memeberId) -> (userConfig.getId().equals(memeberId))).forEach((_item) -> { groupConfigs.add(group); }); } return groupConfigs; }
static ConceptSetMeasure conceptSetMeasure(AnswerProto.ConceptSetMeasure res) { return new ConceptSetMeasure( res.getSet().getIdsList().stream().map(ConceptId::of).collect(toSet()), number(res.getMeasurement()) ); }
public ProjectBinding calculatePathPrefixes(String projectKey, Collection<String> ideFilePaths) { List<Path> idePathList = ideFilePaths.stream() .map(Paths::get) .collect(Collectors.toList()); List<Path> sqPathList = storageReader.readProjectComponents(projectKey) .getComponentList().stream() .map(Paths::get) .collect(Collectors.toList()); FileMatcher fileMatcher = new FileMatcher(new ReversePathTree()); FileMatcher.Result match = fileMatcher.match(sqPathList, idePathList); return new ProjectBinding(projectKey, FilenameUtils.separatorsToUnix(match.sqPrefix().toString()), FilenameUtils.separatorsToUnix(match.idePrefix().toString())); }
private static void processSetting(BiConsumer<String, String> consumer, Setting s) { switch (s.getValueOneOfCase()) { case VALUE: consumer.accept(s.getKey(), s.getValue()); break; case VALUES: consumer.accept(s.getKey(), s.getValues().getValuesList().stream().collect(joining(","))); break; case FIELDVALUES: processPropertySet(s, consumer); break; default: throw new IllegalStateException("Unknow property value for " + s.getKey()); } }
public WorkflowDef fromProto(WorkflowDefPb.WorkflowDef from) { WorkflowDef to = new WorkflowDef(); to.setName( from.getName() ); to.setDescription( from.getDescription() ); to.setVersion( from.getVersion() ); to.setTasks( from.getTasksList().stream().map(this::fromProto).collect(Collectors.toCollection(ArrayList::new)) ); to.setInputParameters( from.getInputParametersList().stream().collect(Collectors.toCollection(ArrayList::new)) ); Map<String, Object> outputParametersMap = new HashMap<String, Object>(); for (Map.Entry<String, Value> pair : from.getOutputParametersMap().entrySet()) { outputParametersMap.put( pair.getKey(), fromProto( pair.getValue() ) ); } to.setOutputParameters(outputParametersMap); to.setFailureWorkflow( from.getFailureWorkflow() ); to.setSchemaVersion( from.getSchemaVersion() ); to.setRestartable( from.getRestartable() ); to.setWorkflowStatusListenerEnabled( from.getWorkflowStatusListenerEnabled() ); return to; }