List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java
public void testPostForDelete() { controller.setLinks(Collections.singletonMap("foo", "http://example.com")); Mockito.when(restTemplate.getForObject(approvalsUri, Set.class)) .thenReturn(Collections.singleton(Collections.singletonMap("clientId", "foo"))); Model model = new ExtendedModelMap(); controller.post(Collections.singleton("read"), null, "", "foo", model); assertTrue(model.containsAttribute("links")); assertTrue(model.containsAttribute("approvals")); }
From source file:de.codecentric.boot.admin.registry.StatusUpdaterTest.java
@Test @SuppressWarnings("rawtypes") public void test_update_statusChanged() { when(template.getForEntity("health", Map.class)) .thenReturn(ResponseEntity.ok().body((Map) Collections.singletonMap("status", "UP"))); updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build()); Application app = store.find("id"); assertThat(app.getStatusInfo().getStatus(), is("UP")); verify(publisher).publishEvent(argThat(isA(ClientApplicationStatusChangedEvent.class))); }
From source file:com.hp.autonomy.frontend.find.hod.configuration.HodConfigurationController.java
@SuppressWarnings("ProhibitedExceptionDeclared") @RequestMapping(value = "/config", method = { RequestMethod.POST, RequestMethod.PUT }) @ResponseBody/*from w ww .ja v a 2 s . com*/ public ResponseEntity<?> saveConfig(@RequestBody final ConfigResponse<HodFindConfig> configResponse) throws Exception { try { log.info(Markers.AUDIT, "REQUESTED CHANGE APPLICATION CONFIGURATION"); configService.updateConfig(configResponse.getConfig()); log.info(Markers.AUDIT, "CHANGED APPLICATION CONFIGURATION"); return new ResponseEntity<>(configService.getConfigResponse(), HttpStatus.OK); } catch (final ConfigException ce) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("exception", ce.getMessage()), HttpStatus.NOT_ACCEPTABLE); } catch (final ConfigValidationException cve) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("validation", cve.getValidationErrors()), HttpStatus.NOT_ACCEPTABLE); } }
From source file:com.thoughtworks.go.config.materials.ScmMaterialConfigTest.java
@Test public void shouldSetFolderToNullWhenBlank() { material.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "foo")); assertThat(material.getFolder(), is(not(nullValue()))); material.setConfigAttributes(new SingletonMap(ScmMaterialConfig.FOLDER, "")); assertThat(material.getFolder(), is(nullValue())); }
From source file:ru.mystamps.web.dao.impl.JdbcUsersActivationDao.java
@Override public UsersActivationDto findByActivationKey(String activationKey) { return jdbcTemplate.queryForObject(findByActivationKeySql, Collections.singletonMap("activation_key", activationKey), RowMappers::forUsersActivationDto); }
From source file:example.springdata.jpa.eclipselink.Application.java
@Override protected Map<String, Object> getVendorProperties() { // Turn off dynamic weaving to disable LTW lookup in static weaving mode return Collections.singletonMap("eclipselink.weaving", "false"); }
From source file:org.craftercms.security.utils.handlers.AbstractRestHandlerBase.java
protected void sendMessage(int status, String message, RequestContext context) throws IOException { sendObject(status, Collections.singletonMap("message", message), context); }
From source file:org.terasoluna.gfw.common.date.jodatime.JdbcAdjustedJodaTimeDateFactoryTest.java
@Test public void testNewDateTime01() throws Exception { jdbcTemplate.update("INSERT INTO system_adjusted_date(diff) VALUES (:diff)", Collections.singletonMap("diff", 30)); // plus 30 minute JdbcAdjustedJodaTimeDateFactory dateFactory = new JdbcAdjustedJodaTimeDateFactory(); dateFactory.setDataSource(dataSource); dateFactory.setAdjustedValueQuery("SELECT diff * 60 * 1000 FROM system_adjusted_date"); // returns diff as minutes DateTime now = new DateTime(); DateTime result = dateFactory.newDateTime(); assertThat((int) (Math.round(result.getMillis() - now.getMillis()) / 60.0 / 1000.0), is(30)); }
From source file:com.thoughtworks.go.server.websocket.ConsoleLogSocket.java
ConsoleLogSocket(ConsoleLogSender handler, JobIdentifier jobIdentifier, SocketHealthService socketHealthService, String consoleLogCharset) { this.handler = handler; this.jobIdentifier = jobIdentifier; this.key = String.format("%s:%d", jobIdentifier, hashCode()); this.socketHealthService = socketHealthService; this.consoleLogCharsetJSONMessage = GSON.toJson(Collections.singletonMap("charset", consoleLogCharset)); }