use of java.util.HashMap in project bazel by bazelbuild.
the class ArtifactFactory method resolveSourceArtifacts.
@Override
public synchronized Map<PathFragment, Artifact> resolveSourceArtifacts(Iterable<PathFragment> execPaths, PackageRootResolver resolver) throws PackageRootResolutionException, InterruptedException {
Map<PathFragment, Artifact> result = new HashMap<>();
ArrayList<PathFragment> unresolvedPaths = new ArrayList<>();
for (PathFragment execPath : execPaths) {
PathFragment execPathNormalized = execPath.normalize();
if (execPathNormalized.containsUplevelReferences()) {
// Source exec paths cannot escape the source root.
result.put(execPath, null);
continue;
}
// First try a quick map lookup to see if the artifact already exists.
Artifact a = sourceArtifactCache.getArtifactIfValid(execPathNormalized);
if (a != null) {
result.put(execPath, a);
} else if (isDerivedArtifact(execPathNormalized)) {
// Don't create an artifact if it's derived.
result.put(execPath, null);
} else {
// Remember this path, maybe we can resolve it with the help of PackageRootResolver.
unresolvedPaths.add(execPath);
}
}
Map<PathFragment, Root> sourceRoots = resolver.findPackageRootsForFiles(unresolvedPaths);
// We are missing some dependencies. We need to rerun this method later.
if (sourceRoots == null) {
return null;
}
for (PathFragment path : unresolvedPaths) {
result.put(path, createArtifactIfNotValid(sourceRoots.get(path), path));
}
return result;
}
use of java.util.HashMap in project bazel by bazelbuild.
the class SkylarkDocumentationCollector method collectJavaObjects.
/**
* Collects and returns all the Java objects reachable in Skylark from (and including)
* firstClass with the corresponding SkylarkModule annotation.
*
* <p>Note that the {@link SkylarkModule} annotation for firstClass - firstModule -
* is also an input parameter, because some top level Skylark built-in objects and methods
* are not annotated on the class, but on a field referencing them.
*/
@VisibleForTesting
static void collectJavaObjects(SkylarkModule firstModule, Class<?> firstClass, Map<String, SkylarkModuleDoc> modules) {
Set<Class<?>> done = new HashSet<>();
Deque<Class<?>> toProcess = new LinkedList<>();
Map<Class<?>, SkylarkModule> annotations = new HashMap<>();
toProcess.addLast(firstClass);
annotations.put(firstClass, firstModule);
while (!toProcess.isEmpty()) {
Class<?> c = toProcess.removeFirst();
SkylarkModule annotation = annotations.get(c);
done.add(c);
if (!modules.containsKey(annotation.name())) {
modules.put(annotation.name(), new SkylarkModuleDoc(annotation, c));
}
SkylarkModuleDoc module = modules.get(annotation.name());
if (module.javaMethodsNotCollected()) {
ImmutableMap<Method, SkylarkCallable> methods = FuncallExpression.collectSkylarkMethodsWithAnnotation(c);
for (Map.Entry<Method, SkylarkCallable> entry : methods.entrySet()) {
module.addMethod(new SkylarkJavaMethodDoc(module, entry.getKey(), entry.getValue()));
}
for (Map.Entry<Method, SkylarkCallable> method : methods.entrySet()) {
Class<?> returnClass = method.getKey().getReturnType();
if (returnClass.isAnnotationPresent(SkylarkModule.class) && !done.contains(returnClass)) {
toProcess.addLast(returnClass);
annotations.put(returnClass, returnClass.getAnnotation(SkylarkModule.class));
}
}
}
}
}
use of java.util.HashMap in project RoboZombie by sahan.
the class RequestParamEndpointTest method testFormParamsMultivaluedFail.
/**
* <p>Test for a {@link Request} having illegal multivalued query parameters.</p>
*
* @since 1.3.0
*/
@Test
public final void testFormParamsMultivaluedFail() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/formparamsmultivaluedfail";
Map<String, List<User>> params = new HashMap<String, List<User>>();
List<User> subjects = new ArrayList<User>();
subjects.add(new User(1, "(En) Sabah", "Nur", 5236, true));
subjects.add(new User(2, "Stephen", "Strange", 41, false));
params.put("subjects", subjects);
stubFor(post(urlMatching(subpath)).willReturn(aResponse().withStatus(200)));
expectedException.expect(Is.isA(InvocationException.class));
requestEndpoint.formParamsMultivaluedFail(params);
}
use of java.util.HashMap in project RoboZombie by sahan.
the class RequestParamEndpointTest method testQueryParamsMultivaluedFail.
/**
* <p>Test for a {@link Request} having illegal multivalued query parameters.</p>
*
* @since 1.3.0
*/
@Test
public final void testQueryParamsMultivaluedFail() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/queryparamsmultivaluedfail";
Map<String, List<User>> params = new HashMap<String, List<User>>();
List<User> subjects = new ArrayList<User>();
subjects.add(new User(1, "(En) Sabah", "Nur", 5236, true));
subjects.add(new User(2, "Stephen", "Strange", 41, false));
params.put("subjects", subjects);
stubFor(get(urlMatching(subpath)).willReturn(aResponse().withStatus(200)));
expectedException.expect(Is.isA(InvocationException.class));
requestEndpoint.queryParamsMultivaluedFail(params);
}
use of java.util.HashMap in project ambari-shell by sequenceiq.
the class ClusterCommandsTest method testAssignForValidHostGroup.
@Test
public void testAssignForValidHostGroup() {
Map<String, List<String>> map = new HashMap<String, List<String>>();
map.put("group1", new ArrayList<String>());
ReflectionTestUtils.setField(clusterCommands, "hostGroups", map);
when(client.getHostNames()).thenReturn(singletonMap("host3", "HEALTHY"));
String result = clusterCommands.assign(new Host("host3"), "group1");
assertEquals("host3 has been added to group1", result);
}
Aggregations