List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:info.mikaelsvensson.devtools.analysis.localaccesslog.LocalAccessLogAnalyzer.java
@Override protected void runImpl(CommandLine commandLine, String[] paths, String reportFileName) throws Exception { for (String path : paths) { File f = new File(path); Collection<File> files = f.isFile() ? Collections.singletonList(f) : (f.isDirectory()/* w w w . j a v a 2s .c o m*/ ? FileUtils.listFiles(f, new PrefixFileFilter("localhost_access_log"), TrueFileFilter.INSTANCE) : Collections.<File>emptyList()); for (File file : files) { LocalAccessLog log = new LocalAccessLog(file); final ReportGenerator reportGenerator = new LocalAccessLogReportGenerator(log); final String pathname = getFormattedString(reportFileName, file); reportGenerator.generateReport(new File(pathname), new PlainTextReportPrinter()); } } }
From source file:com.marathon.hazelcast.servicediscovery.DiscoveryTest.java
@Test public void testSingleMemberDiscovery() throws IOException, InterruptedException { GetAppResponse response = new GetAppResponse(); App app = new App(); app.setId("test_app"); Task task = new Task(); task.setHost("127.0.0.1"); task.setPorts(Collections.singletonList(5701)); app.setTasks(Collections.singletonList(task)); response.setApp(app);//from ww w.ja v a 2 s . c o m stubFor(get(urlEqualTo("/v2/apps/test_app")).willReturn(aResponse().withStatus(200) .withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsBytes(response)))); HazelcastInstance hazelcast = getHazelcastInstance(5701); assertTrue(hazelcast.getCluster().getMembers().size() > 0); hazelcast.shutdown(); }
From source file:com.willwinder.universalgcodesender.gcode.processors.Translator.java
@Override public List<String> processCommand(String command, GcodeState state) throws GcodeParserException { // If the file is in absolute mode, no translation is needed. if (!state.inAbsoluteMode) { return Collections.singletonList(command); }/*ww w . j a v a2 s .c o m*/ String comment = GcodePreprocessorUtils.parseComment(command); String rawCommand = GcodePreprocessorUtils.removeComment(command); List<String> parts = GcodePreprocessorUtils.splitCommand(rawCommand); StringBuilder sb = new StringBuilder(); double x = offset.getPositionIn(UnitUtils.Units.getUnits(state.units)).x; double y = offset.getPositionIn(UnitUtils.Units.getUnits(state.units)).y; double z = offset.getPositionIn(UnitUtils.Units.getUnits(state.units)).z; for (String part : parts) { switch (Character.toUpperCase(part.charAt(0))) { case 'X': sb.append(shift(part, x)); break; case 'Y': sb.append(shift(part, y)); break; case 'Z': sb.append(shift(part, z)); break; // Grbl doesn't support absolute arcs, but what the hell. case 'I': if (state.inAbsoluteIJKMode) { sb.append(shift(part, x)); break; } // fall through if not in absolute mode... case 'J': if (state.inAbsoluteIJKMode) { sb.append(shift(part, y)); break; } // fall through if not in absolute mode... case 'K': if (state.inAbsoluteIJKMode) { sb.append(shift(part, z)); break; } // fall through if not in absolute mode... default: sb.append(part); } } if (StringUtils.isNotBlank(comment)) { sb.append("(").append(comment).append(")"); } return Collections.singletonList(sb.toString()); }
From source file:org.springframework.security.jackson2.UserDeserializerTests.java
@Test public void serializeUserTest() throws JsonProcessingException, JSONException { ObjectMapper mapper = buildObjectMapper(); User user = new User("admin", "1234", Collections.singletonList(new SimpleGrantedAuthority("USER_ROLE"))); String userJson = mapper.writeValueAsString(user); String expectedJson = "{\"@class\": \"org.springframework.security.core.userdetails.User\", \"username\": \"admin\", \"password\": \"1234\", \"accountNonExpired\": true, \"accountNonLocked\": true, \"credentialsNonExpired\": true, \"enabled\": true, \"authorities\": [\"java.util.Collections$UnmodifiableSet\", [{\"@class\": \"org.springframework.security.core.authority.SimpleGrantedAuthority\", \"role\": \"USER_ROLE\"}]]}"; JSONAssert.assertEquals(expectedJson, userJson, true); }
From source file:org.talend.dataprep.command.CommandHelper.java
public static ResponseEntity<Void> async(final GenericCommand<?> command) { final Observable<?> stream = command.toObservable(); return stream.map(is -> { // copy all headers from the command response so that the mime-type is correctly forwarded. Command has // the correct headers due to call to toBlocking() below. final MultiValueMap<String, String> headers = new HttpHeaders(); HttpStatus status = command.getStatus(); for (Header header : command.getCommandResponseHeaders()) { headers.put(header.getName(), Collections.singletonList(header.getValue())); }//from ww w . j a va2 s. c o m return new ResponseEntity<Void>(null, headers, status); }).toBlocking().first(); }
From source file:com.cloudera.cdk.morphline.stdlib.GenerateUUIDBuilder.java
@Override public Collection<String> getNames() { return Collections.singletonList("generateUUID"); }
From source file:eu.over9000.cathode.data.parameters.EmoteSets.java
@Override public List<NameValuePair> buildParamPairs() { if (emoteSets.isEmpty()) { return Collections.emptyList(); }/*from w w w. j a va 2 s . co m*/ return Collections.singletonList(new BasicNameValuePair("emotesets", String.join(",", emoteSets))); }
From source file:nl.surfnet.coin.api.saml.SAMLProvisioner.java
@Override public UserDetails provisionUser(Assertion assertion) { String userId = getValueFromAttributeStatements(assertion, uuidAttribute); Assert.hasLength(userId, "SAML assertion does not contain required personId (" + uuidAttribute + ")"); return new User(userId, "N/A", Collections.singletonList(new SimpleAuthority("USER"))); }
From source file:de.egore911.versioning.deployer.performer.PerformRelacementTest.java
@Test public void testPerformFile() throws IOException { String tmpdir = System.getProperty("java.io.tmpdir"); File propertiesFile = new File(UrlUtil.concatenateUrlWithSlashes(tmpdir, "myfile.properties")); File replacementProperties = new File(UrlUtil.concatenateUrlWithSlashes(tmpdir, "replacement.properties")); FileUtils.write(replacementProperties, "testvariable = testvalue"); FileUtils.write(propertiesFile, "Test = ${versioning:testvariable}"); PerformReplacement.perform(new File(tmpdir), Collections.singletonList("*.properties"), new ArrayList<ReplacementPair>(), Collections.singletonList(replacementProperties)); Assert.assertEquals("Test = testvalue", FileUtils.readFileToString(propertiesFile)); }