Example usage for java.util Collections emptySet

List of usage examples for java.util Collections emptySet

Introduction

In this page you can find the example usage for java.util Collections emptySet.

Prototype

@SuppressWarnings("unchecked")
public static final <T> Set<T> emptySet() 

Source Link

Document

Returns an empty set (immutable).

Usage

From source file:com.navercorp.pinpoint.web.alarm.checker.DeadlockCheckerTest.java

@Test
public void checkTest2() {
    Rule rule = new Rule(APPLICATION_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 50, "testGroup",
            false, false, "");
    Application application = new Application(APPLICATION_NAME, ServiceType.STAND_ALONE);

    Range range = Range.createUncheckedRange(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
    when(mockAgentEventDao.getAgentEvents(AGENT_ID_1, range, Collections.emptySet())).thenReturn(Arrays.asList(
            createAgentEvent(AGENT_ID_1, createEventTimestamp(), AgentEventType.AGENT_CLOSED_BY_SERVER)));
    when(mockAgentEventDao.getAgentEvents(AGENT_ID_2, range, Collections.emptySet())).thenReturn(
            Arrays.asList(createAgentEvent(AGENT_ID_2, createEventTimestamp(), AgentEventType.AGENT_SHUTDOWN)));
    when(mockAgentEventDao.getAgentEvents(AGENT_ID_3, range, Collections.emptySet())).thenReturn(
            Arrays.asList(createAgentEvent(AGENT_ID_3, createEventTimestamp(), AgentEventType.AGENT_PING)));

    AgentEventDataCollector dataCollector = new AgentEventDataCollector(
            DataCollectorFactory.DataCollectorCategory.AGENT_EVENT, application, mockAgentEventDao,
            mockApplicationIndexDao, CURRENT_TIME_MILLIS, INTERVAL_MILLIS);
    DeadlockChecker checker = new DeadlockChecker(dataCollector, rule);
    checker.check();/*  ww w.  ja  v  a2 s.co  m*/
    Assert.assertFalse(checker.isDetected());

    String emailMessage = checker.getEmailMessage();
    Assert.assertTrue(StringUtils.isEmpty(emailMessage));

    List<String> smsMessage = checker.getSmsMessage();
    Assert.assertTrue(smsMessage.isEmpty());
}

From source file:org.leandreck.endpoints.processor.model.TypeNode.java

public Set<EnumValue> getEnumValues() {
    return Collections.emptySet();
}

From source file:org.ireas.mediawiki.DefaultMediaWiki.java

@Override
public int getContribCount(final String user, final int limit) throws MediaWikiException {
    Preconditions.checkNotNull(user);/*from w  w w. j a v  a2s  . c om*/
    Preconditions.checkArgument(limit > 0);

    Set<Namespace> namespaces = Collections.emptySet();
    return getContribCount(user, limit, namespaces);
}

From source file:net.sourceforge.vulcan.web.struts.MockApplicationContextStrutsTestCase.java

@Override
public void setUp() throws Exception {
    super.setUp();

    context = new ServletContextSimulator() {
        @Override/*from w  w w  . j  a  v  a 2 s  .c  o m*/
        public Set<String> getResourcePaths(String path) {
            return Collections.emptySet();
        }
    };
    config = new ServletConfigSimulator() {
        @Override
        public ServletContext getServletContext() {
            return context;
        }
    };
    request = new HttpServletRequestSimulator(config.getServletContext());
    response = new HttpServletResponseSimulator();

    request.setServerName("localhost");
    request.setServerPort(80);
    context.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    multipartElements.clear();

    setContextDirectory(TestUtils.resolveRelativeFile("source/main/docroot"));

    setRequestProcessor(new RequestProcessor() {
        @Override
        protected ActionForward processException(HttpServletRequest request, HttpServletResponse response,
                Exception exception, ActionForm form, ActionMapping mapping)
                throws IOException, ServletException {

            throw new UncaughtExceptionError(exception);
        }

        @Override
        protected void processForwardConfig(HttpServletRequest request, HttpServletResponse response,
                ForwardConfig forward) throws IOException, ServletException {

            resultForward = (ActionForward) forward;

            super.processForwardConfig(request, response, forward);
        }

        @Override
        protected boolean processValidate(HttpServletRequest request, HttpServletResponse response,
                ActionForm form, ActionMapping mapping)
                throws IOException, ServletException, InvalidCancelException {

            boolean result = super.processValidate(request, response, form, mapping);

            if (result == false) {
                // validation failed, use ActionMapping "input" param as forward
                resultForward = mapping.getInputForward();
            }
            return result;
        }
    });

    context.setAttribute(Keys.STATE_MANAGER, manager);

    context.setAttribute("javax.servlet.context.tempdir", new File(System.getProperty("java.io.tmpdir")));
}

From source file:cpcc.vvrte.services.js.JavascriptWorker.java

/**
 * {@inheritDoc}//from w w  w.j  a v a  2  s. co m
 */
@Override
public void run() {
    String name = Thread.currentThread().getName();
    Thread.currentThread().setName("Virtual Vehicle: " + vehicle.getName() + " (" + vehicle.getId() + ")");

    HibernateSessionManager sessionManager = serviceResources.getService(HibernateSessionManager.class);

    applicationState = null;

    changeState(sessionManager, VirtualVehicleState.RUNNING);

    if (snapshot == null && script == null) {
        changeState(sessionManager, VirtualVehicleState.DEFECTIVE);
        sessionManager.commit();
        serviceResources.getService(PerthreadManager.class).cleanup();
        return;
    }

    Context cx = Context.enter();
    cx.setOptimizationLevel(-1);
    ScriptableObject scope = cx.initStandardObjects();
    try {
        cx.setClassShutter(new SandboxClassShutter(Collections.emptySet(), allowedClassesRegex));
        scope.defineFunctionProperties(VvRteFunctions.FUNCTIONS, VvRteFunctions.class,
                ScriptableObject.DONTENUM);

        Object resultObj;
        if (snapshot == null) {
            Script compiledScript = cx.compileString(script, "<vehicle>", 1, null);
            resultObj = cx.executeScriptWithContinuations(compiledScript, scope);
        } else {
            ByteArrayInputStream bais = new ByteArrayInputStream(snapshot);
            ScriptableInputStream sis = new ScriptableInputStream(bais, scope);
            Scriptable globalScope = (Scriptable) sis.readObject();
            Object c = sis.readObject();
            sis.close();
            bais.close();
            resultObj = cx.resumeContinuation(c, globalScope, Boolean.TRUE);
        }

        logger.info("Result obj: " + Context.toString(resultObj));
        result = Context.toString(resultObj);

        changeState(sessionManager, VirtualVehicleState.FINISHED);
    } catch (ContinuationPending cp) {
        logger.info("Application State " + cp.getApplicationState());
        applicationState = (ApplicationState) cp.getApplicationState();
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ScriptableOutputStream sos = new ScriptableOutputStream(baos, scope);
            sos.excludeStandardObjectNames();
            sos.writeObject(scope);
            sos.writeObject(cp.getContinuation());
            sos.close();
            baos.close();
            snapshot = baos.toByteArray();

            if (applicationState.isTask()) {
                changeState(sessionManager, VirtualVehicleState.TASK_COMPLETION_AWAITED);
            } else {
                changeState(sessionManager, VirtualVehicleState.INTERRUPTED);
            }

            logger.info("snapshot is " + snapshot.length + " bytes long.");
        } catch (IOException e) {
            logger.error("Defective: VV=" + vehicle.getName() + " (" + vehicle.getId() + " / "
                    + vehicle.getUuid() + ")", e);
            result = ExceptionFormatter.toString(e);
            snapshot = null;
            changeState(sessionManager, VirtualVehicleState.DEFECTIVE);
        }
    } catch (RhinoException e) {
        logger.error(
                "Defective: VV=" + vehicle.getName() + " (" + vehicle.getId() + " / " + vehicle.getUuid() + ")",
                e);
        result = e.getMessage() + ", line=" + (e.lineNumber() - scriptStartLine) + ":" + e.columnNumber()
                + ", source='" + e.lineSource() + "'";
        changeState(sessionManager, VirtualVehicleState.DEFECTIVE);
    } catch (ClassNotFoundException | IOException | NoSuchMethodError e) {
        logger.error(
                "Defective: VV=" + vehicle.getName() + " (" + vehicle.getId() + " / " + vehicle.getUuid() + ")",
                e);
        result = ExceptionFormatter.toString(e);
        changeState(sessionManager, VirtualVehicleState.DEFECTIVE);
    } finally {
        Context.exit();
        sessionManager.commit();
        serviceResources.getService(PerthreadManager.class).cleanup();
        Thread.currentThread().setName(name);
    }
}

From source file:ca.uhn.fhir.jpa.dao.dstu3.SearchParamExtractorDstu3.java

@Override
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity,
        IBaseResource theResource) {/*from   w  w  w .java  2s . c o  m*/
    // TODO: implement
    return Collections.emptySet();
}

From source file:com.dianping.dpsf.jmx.DpsfResponsorMonitor.java

@MBeanMeta(ignore = true)
public Collection<String> requestorsAtPort(int port) {
    Collection<String> requestors = new HashSet<String>();
    RequestProcessor requestProcessor = getRequestProcessor(port);
    if (requestProcessor == null) {
        return Collections.emptySet();
    }//from  www.  j a va  2 s .co m
    ChannelGroup serverChannels = requestProcessor.getServerChannels();
    for (Channel channel : serverChannels) {
        InetSocketAddress remoteAddress = (InetSocketAddress) channel.getRemoteAddress();
        requestors.add(remoteAddress.getAddress().getHostAddress() + ":" + remoteAddress.getPort());
    }
    return requestors;
}

From source file:io.fd.maintainer.plugin.util.MaintainersIndex.java

public Tuple2<Set<ComponentPath>, Set<ComponentPath>> getComponentPathsForEntry(
        @Nonnull final PatchListEntry entry) {
    final LinkedListMultimap<MatchLevel, ComponentPath> byMatchIndexOld = LinkedListMultimap.create();
    final LinkedListMultimap<MatchLevel, ComponentPath> byMatchIndexNew = LinkedListMultimap.create();
    pathToMaintainersIndex//  w w w.j  a v a2s.  co m
            .forEach((key, value) -> byMatchIndexOld.put(key.matchAgainst(entry.getOldName()), key));

    pathToMaintainersIndex
            .forEach((key, value) -> byMatchIndexNew.put(key.matchAgainst(entry.getNewName()), key));

    final MatchLevel maxMatchLevelOld = maxMatchLevel(byMatchIndexOld.keys());
    final MatchLevel maxMatchLevelNew = maxMatchLevel(byMatchIndexNew.keys());

    final int mostSpecificLengthOld = mostSpecificPathLengthFromComponent(maxMatchLevelOld, byMatchIndexOld);
    final int mostSpecificLengthNew = mostSpecificPathLengthFromComponent(maxMatchLevelOld, byMatchIndexOld);

    final Set<ComponentPath> oldComponents = NONE == maxMatchLevelOld ? Collections.emptySet()
            : new HashSet<>(byMatchIndexOld.get(maxMatchLevelOld).stream()
                    .filter(componentPath -> getPathLength(componentPath.getPath()) == mostSpecificLengthOld)
                    .collect(Collectors.toList()));

    final Set<ComponentPath> newComponents = NONE == maxMatchLevelNew ? Collections.emptySet()
            : new HashSet<>(byMatchIndexNew.get(maxMatchLevelNew).stream()
                    .filter(componentPath -> getPathLength(componentPath.getPath()) == mostSpecificLengthNew)
                    .collect(Collectors.toList()));

    return new Tuple2<>(oldComponents, newComponents);
}

From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandlerTest.java

@Test
public void testHttpRequestMethodNotSupported() {
    Set<String> allowedMethods = Sets.newLinkedHashSet(Lists.newArrayList("GET", "POST"));
    ResponseEntity<Object> response = //
            performTest(new HttpRequestMethodNotSupportedException("PUT", allowedMethods), //
                    400, "methodNotAllowed");
    HttpHeaders headers = response.getHeaders();
    assertEquals(1, headers.size());/*  w  ww .j a  v  a2s.  c  om*/
    Set<String> actualAllow = new HashSet<String>();

    for (HttpMethod method : headers.getAllow()) {
        actualAllow.add(method.name());
    }
    assertEquals(allowedMethods, actualAllow);

    allowedMethods = Collections.emptySet();
    response = //
            performTest(new HttpRequestMethodNotSupportedException("PUT", allowedMethods), //
                    400, "methodNotAllowed");
    headers = response.getHeaders();
    assertEquals(0, headers.size());
}

From source file:com.steelbridgelabs.oss.neo4j.structure.Neo4JGraph.java

/**
 * Creates a {@link Neo4JGraph} instance.
 *
 * @param driver           The {@link Driver} instance with the database connection information.
 * @param vertexIdProvider The {@link Neo4JElementIdProvider} for the {@link Vertex} id generation.
 * @param edgeIdProvider   The {@link Neo4JElementIdProvider} for the {@link Edge} id generation.
 *///from   w  w  w .  ja  v  a 2s  .  co  m
public Neo4JGraph(Driver driver, Neo4JElementIdProvider<?> vertexIdProvider,
        Neo4JElementIdProvider<?> edgeIdProvider) {
    Objects.requireNonNull(driver, "driver cannot be null");
    Objects.requireNonNull(vertexIdProvider, "vertexIdProvider cannot be null");
    Objects.requireNonNull(edgeIdProvider, "edgeIdProvider cannot be null");
    // no label partition
    this.partition = new NoReadPartition();
    this.vertexLabels = Collections.emptySet();
    // store driver instance
    this.driver = driver;
    // store providers
    this.vertexIdProvider = vertexIdProvider;
    this.edgeIdProvider = edgeIdProvider;
}