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.zenoss.zep.dao.impl.EventTriggerDaoImpl.java
@Override @TransactionalRollbackAllExceptions//w w w . j av a 2 s . c o m public int delete(String uuidStr) throws ZepException { final Map<String, Object> fields = Collections.singletonMap(COLUMN_UUID, uuidConverter.toDatabaseType(uuidStr)); return this.template.update("DELETE FROM event_trigger WHERE uuid=:uuid", fields); }
From source file:se.inera.intyg.intygstjanst.web.integration.stub.FkStubResource.java
@POST @Path("/clear") @Produces(MediaType.APPLICATION_JSON)/*from www . j a v a 2s.com*/ public Map<String, String> clearJson() { fkMedicalCertificatesStore.clear(); Collections.singletonMap("result", "ok"); return Collections.singletonMap("result", "ok"); }
From source file:io.fabric8.maven.enricher.standard.DefaultControllerEnricherTest.java
protected void setupExpectations(final BuildImageConfiguration buildConfig, final TreeMap controllerConfig) { new Expectations() { {//from www .ja va 2 s . c om project.getArtifactId(); result = "fmp-controller-test"; project.getBuild().getOutputDirectory(); result = Files.createTempDir().getAbsolutePath(); context.getProject(); result = project; context.getConfig(); result = new ProcessorConfig(null, null, Collections.singletonMap("fmp-controller", controllerConfig)); imageConfiguration.getBuildConfiguration(); result = buildConfig; imageConfiguration.getName(); result = "helloworld"; context.getImages(); result = Arrays.asList(imageConfiguration); } }; }
From source file:org.cloudfoundry.identity.uaa.oauth.ClientAdminBootstrapTests.java
@Test public void testOverrideClient() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put("secret", "bar"); map.put("override", true); bootstrap.setClients(Collections.singletonMap("foo", map)); doThrow(new ClientAlreadyExistsException("Planned")).when(clientRegistrationService) .addClientDetails(any(ClientDetails.class)); bootstrap.afterPropertiesSet();//www . j a va 2s. co m verify(clientRegistrationService, times(1)).addClientDetails(any(ClientDetails.class)); verify(clientRegistrationService, times(1)).updateClientDetails(any(ClientDetails.class)); verify(clientRegistrationService, times(1)).updateClientSecret("foo", "bar"); }
From source file:com.arrow.acn.client.api.SoftwareReleaseTransApi.java
public StatusModel failed(String hid, String error) { String method = "failed"; try {/* w ww .j a va2 s. c o m*/ URI uri = buildUri(String.format(FAILED_URL, hid)); StatusModel result = execute(new HttpPut(uri), JsonUtils.toJson(Collections.singletonMap("error", AcsUtils.trimToEmpty(error))), StatusModel.class); log(method, result); return result; } catch (Throwable e) { logError(method, e); throw new AcnClientException(method, e); } }
From source file:com.yahoo.glimmer.web.QueryController.java
@RequestMapping(value = "/indexStatistics", method = RequestMethod.GET) public Map<String, ?> getIndexStatistics(@ModelAttribute(INDEX_KEY) RDFIndex index, @RequestParam(required = false) String callback) { if (index == null) { throw new HttpMessageConversionException("No index given"); }/*ww w .jav a2 s. c om*/ RDFIndexStatistics statistics = index.getStatistics(); return Collections.singletonMap(OBJECT_KEY, statistics); }
From source file:org.callimachusproject.test.WebResource.java
public WebResource create(String slug, String type, byte[] body) throws IOException { return create(Collections.singletonMap("Slug", slug), type, body); }
From source file:org.elasticsearch.client.CrudIT.java
public void testDelete() throws IOException { {// ww w . j a va 2 s.c o m // Testing non existing document String docId = "does_not_exist"; DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.NOT_FOUND, deleteResponse.getResult()); } { // Testing deletion String docId = "id"; highLevelClient() .index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); if (randomBoolean()) { deleteRequest.version(1L); } DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } { // Testing version conflict String docId = "version_conflict"; highLevelClient() .index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync)); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + docId + "]: " + "version conflict, current version [1] is different than the one provided [2]]", exception.getMessage()); assertEquals("index", exception.getMetadata("es.index").get(0)); } { // Testing version type String docId = "version_type"; highLevelClient().index(new IndexRequest("index", "type", docId) .source(Collections.singletonMap("foo", "bar")).versionType(VersionType.EXTERNAL).version(12)); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId) .versionType(VersionType.EXTERNAL).version(13); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } { // Testing version type with a wrong version String docId = "wrong_version"; highLevelClient().index(new IndexRequest("index", "type", docId) .source(Collections.singletonMap("foo", "bar")).versionType(VersionType.EXTERNAL).version(12)); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId) .versionType(VersionType.EXTERNAL).version(10); execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + docId + "]: version conflict, current version [12] is higher or equal to the one provided [10]]", exception.getMessage()); assertEquals("index", exception.getMetadata("es.index").get(0)); } { // Testing routing String docId = "routing"; highLevelClient().index(new IndexRequest("index", "type", docId) .source(Collections.singletonMap("foo", "bar")).routing("foo")); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).routing("foo"); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } }
From source file:com.thoughtworks.go.config.update.DeleteArtifactStoreConfigCommand.java
private void populateReferences(List<Map<JobConfigIdentifier, List<PluggableArtifactConfig>>> usedByPipelines, PipelineConfig pipelineConfig) { for (StageConfig stage : pipelineConfig) { JobConfigs jobs = stage.getJobs(); for (JobConfig job : jobs) { final List<PluggableArtifactConfig> artifactConfigs = job.artifactConfigs() .findByStoreId(profile.getId()); if (!artifactConfigs.isEmpty()) { usedByPipelines.add(Collections.singletonMap( new JobConfigIdentifier(pipelineConfig.name(), stage.name(), job.name()), artifactConfigs)); }/*ww w . ja v a2s. c o m*/ } } }
From source file:org.cloudfoundry.identity.uaa.oauth.CheckTokenEndpointTests.java
public CheckTokenEndpointTests() { authentication = new OAuth2Authentication( new DefaultAuthorizationRequest("client", Collections.singleton("read")), UaaAuthenticationTestFactory.getAuthentication("12345", "olds", "olds@vmware.com")); SignerProvider signerProvider = new SignerProvider(); signerProvider.setSigningKey("abc"); signerProvider.setVerifierKey("abc"); tokenServices.setSignerProvider(signerProvider); endpoint.setTokenServices(tokenServices); Date oneSecondAgo = new Date(System.currentTimeMillis() - 1000); Date thirtySecondsAhead = new Date(System.currentTimeMillis() + 30000); UaaUserDatabase userDatabase = new MockUaaUserDatabase("12345", "olds", "olds@vmware.com", null, null, oneSecondAgo, oneSecondAgo); tokenServices.setUserDatabase(userDatabase); approvalStore.addApproval(//from w w w .java 2 s.c o m new Approval("olds", "client", "read", thirtySecondsAhead, ApprovalStatus.APPROVED, oneSecondAgo)); approvalStore.addApproval( new Approval("olds", "client", "write", thirtySecondsAhead, ApprovalStatus.APPROVED, oneSecondAgo)); tokenServices.setApprovalStore(approvalStore); Map<String, ? extends ClientDetails> clientDetailsStore = Collections.singletonMap("client", new BaseClientDetails("client", "scim, cc", "read, write", "authorization_code, password", "scim.read, scim.write", "http://localhost:8080/uaa")); clientDetailsService.setClientDetailsStore(clientDetailsStore); tokenServices.setClientDetailsService(clientDetailsService); accessToken = tokenServices.createAccessToken(authentication); }