Search in sources :

Example 61 with HashMap

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;
}
Also used : HashMap(java.util.HashMap) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ArrayList(java.util.ArrayList)

Example 62 with HashMap

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));
                }
            }
        }
    }
}
Also used : SkylarkCallable(com.google.devtools.build.lib.skylarkinterface.SkylarkCallable) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) LinkedList(java.util.LinkedList) SkylarkJavaMethodDoc(com.google.devtools.build.docgen.skylark.SkylarkJavaMethodDoc) SkylarkModule(com.google.devtools.build.lib.skylarkinterface.SkylarkModule) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SkylarkModuleDoc(com.google.devtools.build.docgen.skylark.SkylarkModuleDoc) HashSet(java.util.HashSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 63 with HashMap

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);
}
Also used : User(com.lonepulse.robozombie.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) InvocationException(com.lonepulse.robozombie.proxy.InvocationException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 64 with HashMap

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);
}
Also used : User(com.lonepulse.robozombie.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) InvocationException(com.lonepulse.robozombie.proxy.InvocationException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 65 with HashMap

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)29051 ArrayList (java.util.ArrayList)7306 Map (java.util.Map)6569 Test (org.junit.Test)6315 List (java.util.List)3204 IOException (java.io.IOException)2753 HashSet (java.util.HashSet)2366 Set (java.util.Set)1616 File (java.io.File)1440 LinkedHashMap (java.util.LinkedHashMap)1417 Iterator (java.util.Iterator)1273 Test (org.testng.annotations.Test)1048 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)865 ApiResponse (io.kubernetes.client.ApiResponse)707 Pair (io.kubernetes.client.Pair)707 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)707 Date (java.util.Date)590 LinkedList (java.util.LinkedList)574 Properties (java.util.Properties)507 URI (java.net.URI)474