List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:com.arrow.acn.client.api.CoreEventApi.java
public StatusModel putFailed(String hid, String error) { String method = "putFailed"; try {/*from ww w . j ava 2 s . c o m*/ URI uri = buildUri(PUT_FAILED_URL.replace("{hid}", hid)); StatusModel result = execute(new HttpPut(uri), JsonUtils.toJson(Collections.singletonMap("error", error)), StatusModel.class); log(method, result); return result; } catch (Throwable e) { logError(method, e); throw new AcnClientException(method, e); } }
From source file:org.terasoluna.gfw.functionaltest.domain.service.download.DownloadServiceImpl.java
@Override public InputStream findContentsById(int documentId) { InputStream contentsStream = jdbcTemplate.queryForObject(FIND_CONTENTS_BY_ID, Collections.singletonMap("documentId", documentId), new RowMapper<InputStream>() { public InputStream mapRow(ResultSet rs, int i) throws SQLException { InputStream blobStream = lobHandler.getBlobAsBinaryStream(rs, "contents"); return blobStream; }// w w w. ja v a2 s.c o m }); return contentsStream; }
From source file:nu.yona.server.messaging.service.BuddyMessageEmbeddedUserDto.java
public void setEmbeddedUser(String rel, Object userResource) { embeddedResources = Collections.singletonMap(rel, userResource); }
From source file:com.puppetlabs.geppetto.forge.v1.service.ModuleService.java
/** * @param keyword/*from www .j ava 2 s .c o m*/ * KeyWord to use in the search. May be <code>null</code> to get all modules. * @return All Modules that matches the given keyword * @throws IOException */ public List<ModuleInfo> search(String keyword) throws IOException { List<ModuleInfo> modules = null; try { modules = forgeClient.getV1(Constants.COMMAND_GROUP_MODULES, keyword == null ? null : Collections.singletonMap("q", keyword), Constants.LIST_MODULE_INFO); } catch (HttpResponseException e) { if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) throw e; } if (modules == null) modules = Collections.emptyList(); return modules; }
From source file:com.puppetlabs.geppetto.forge.v1.impl.DefaultModuleService.java
@Override public List<ModuleInfo> search(String keyword) throws IOException { List<ModuleInfo> modules = null; try {// w ww. j a v a2 s. co m modules = forgeClient.getV1(Constants.COMMAND_GROUP_MODULES, keyword == null ? null : Collections.singletonMap("q", keyword), LIST_MODULE_INFO); } catch (HttpResponseException e) { if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) throw e; } if (modules == null) modules = Collections.emptyList(); return modules; }
From source file:com.whizzosoftware.hobson.dto.data.DataStreamDataDTOTest.java
@Test public void testToJSON() { DataStreamDataDTO dto = new DataStreamDataDTO.Builder( new ManagerDTOBuildContext.Builder().idProvider(new ContextPathIdProvider()).build(), "ds1", 2000, DataStreamInterval.HOURS_1)// w w w . j a v a 2 s .c o m .fields(Collections.singletonList(new DataStreamField("field1", "fieldName1", VariableContext.createLocal("plugin1", "device1", "var1")))) .data(Collections.singletonList( new DataStreamValueSet(1000, Collections.singletonMap("field1", (Object) 100)))) .build(); JSONObject json = dto.toJSON(); assertEquals(2000, json.getInt("endTime")); JSONObject f = json.getJSONObject("fields"); assertEquals("fieldName1", f.getString("field1")); JSONArray a = json.getJSONArray("data"); assertEquals(1, a.length()); assertEquals(1000, a.getJSONObject(0).getInt("timestamp")); assertEquals(100, a.getJSONObject(0).getInt("field1")); }
From source file:com.graphaware.server.TxParticipationIntegrationTest.java
@Test public void nonExistingTransactionShouldResultInException() { System.out.println(get(baseUrl() + "/graphaware/greeting", Collections.singletonMap("_GA_TX_ID", "1"), HttpStatus.SC_BAD_REQUEST)); }
From source file:org.cloudfoundry.identity.uaa.oauth.AccessControllerTests.java
@Test public void testSunnyDay() throws Exception { InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService(); clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", new BaseClientDetails())); controller.setClientDetailsService(clientDetailsService); controller.setApprovalStore(Mockito.mock(ApprovalStore.class)); Authentication auth = UaaAuthenticationTestFactory.getAuthentication("foo@bar.com", "Foo Bar", "foo@bar.com"); String result = controller.confirm(new ModelMap(), new MockHttpServletRequest(), auth, new SimpleSessionStatus()); assertEquals("access_confirmation", result); }
From source file:ro.lmn.presos.di.emailsender.impl.spring.EmailSender.java
public void sendMail(String subject, String template) { for (String recipient : recipientFinder.findRecipients()) { String finalText = textFormatter.formatText(template, Collections.singletonMap("product", "v1agRa")); smtpService.send(recipient, subject, finalText); }// ww w . ja va 2s .c om }
From source file:org.jasig.portlet.widget.servlet.mvc.YouTubeController.java
@RequestMapping public ModelAndView getFeed(@RequestParam("user") String user) { String response = service.getYouTubeResponse(user); return new ModelAndView("/string", Collections.singletonMap("response", response)); }