List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:de.taimos.dvalin.interconnect.core.spring.test.BrokerMock.java
/** * @param destination the destination name * @param topic <code>true</code> for topic; <code>false</code> for queue * @param ico the object to send * @param headers optional headers/*w ww. jav a2 s. c o m*/ */ public void send(final String destination, final boolean topic, final InterconnectObject ico, final DaemonMessageSenderHeader... headers) { // Check registered RequestMocks if (this.requestMock.hasHandler(destination)) { UUID uuid = null; for (DaemonMessageSenderHeader head : headers) { if (head.getField() == DaemonMessageSenderHeader.Field.RequestUUID) { uuid = UUID.fromString((String) head.getValue()); } } this.requestMock.receive(uuid == null ? UUID.randomUUID() : uuid, destination, ico); return; } final String destName = (topic ? "topic://" : "queue://") + destination; if (!BrokerMock.this.listeners.containsKey(destName)) { BrokerMock.LOGGER.error("Missing destination {}", destName); throw new RuntimeException(); } this.exec.execute(new Runnable() { @Override public void run() { try { final ActiveMQDestination dest; if (topic) { dest = new ActiveMQTopic(destination); } else { dest = new ActiveMQQueue(destination); } ActiveMQTextMessage msg = new ActiveMQTextMessage(); msg.setDestination(dest); msg.setText(InterconnectMapper.toJson(ico)); msg.setObjectProperty(InterconnectConnector.HEADER_ICO_CLASS, ico.getClass().getName()); if (headers != null) { for (DaemonMessageSenderHeader header : headers) { msg.setObjectProperty(header.getField().getName(), header.getValue()); } } BrokerMock.this.listeners.get(destName).onMessage(msg); } catch (Exception e) { BrokerMock.LOGGER.error("Failed to send message", e); } } }); }
From source file:controllers.AlertControllerTest.java
@Test public void testCreateValidCase() throws IOException { Http.RequestBuilder request = new Http.RequestBuilder().method("PUT") .bodyJson(readTree("testCreateValidCase")).header("Content-Type", "application/json") .uri("/v1/alerts"); Result result = Helpers.route(request); Assert.assertEquals(Http.Status.OK, result.status()); final models.ebean.Alert alert = Ebean.find(models.ebean.Alert.class).where() .eq("uuid", UUID.fromString("88410734-aed7-11e1-8e54-00259060b612")).findUnique(); Assert.assertNotNull(alert);//from w w w. j av a2s . c o m Assert.assertEquals(Context.CLUSTER, alert.getContext()); Assert.assertEquals("test-cluster", alert.getCluster()); Assert.assertEquals("test-name", alert.getName()); Assert.assertEquals("test-metric", alert.getMetric()); Assert.assertEquals("test-service", alert.getService()); Assert.assertEquals(1, alert.getPeriod()); Assert.assertEquals(Operator.EQUAL_TO, alert.getOperator()); Assert.assertEquals(12, alert.getQuantityValue(), 0.01); Assert.assertEquals("MEGABYTE", alert.getQuantityUnit()); final NagiosExtension extension = alert.getNagiosExtension(); Assert.assertNotNull(extension); Assert.assertEquals("CRITICAL", extension.getSeverity()); Assert.assertEquals("abc@example.com", extension.getNotify()); Assert.assertEquals(3, extension.getMaxCheckAttempts()); Assert.assertEquals(300, extension.getFreshnessThreshold()); }
From source file:org.usergrid.rest.management.users.UsersResource.java
@Path("{userId: [A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}}") public UserResource getUserById(@Context UriInfo ui, @PathParam("userId") String userIdStr) throws Exception { return getSubResource(UserResource.class).init(management.getAdminUserByUuid(UUID.fromString(userIdStr))); }
From source file:org.trustedanalytics.servicebroker.hdfs.plans.HdfsPlanCreateUserDirectory.java
@Override public void provision(ServiceInstance serviceInstance, Optional<Map<String, Object>> parameters) throws ServiceInstanceExistsException, ServiceBrokerException { UUID instanceId = UUID.fromString(serviceInstance.getServiceInstanceId()); UUID orgId = UUID.fromString(serviceInstance.getOrganizationGuid()); String password = RandomStringUtils.randomAlphanumeric(32); UUID sysUser = groupMappingOperations.createSysUser(orgId, instanceId, password); hdfsOperations.provisionDirectory(instanceId, orgId, sysUser); credentialsStore.save(ImmutableMap.of(USER, instanceId.toString(), PASSWORD, password), instanceId); }
From source file:com.boxedfolder.domain.TransactionLogRepositoryTests.java
@Before public void setup() { logRepository = new TransactionLogRepositoryImpl(); logRepository.setEntityManager(entityManager); prevDate = DateTime.now().minus(1000); app = new App(); app.setDateCreated(new DateTime()); app.setDateUpdated(new DateTime()); app.setName("Testapp"); app.setApplicationKey(UUID.fromString("550e8400-e29b-11d4-a716-446655440001")); entityManager.persist(app);// ww w . j a v a2s. c om App secondApp = new App(); secondApp.setDateCreated(new DateTime()); secondApp.setName("Testapp 2"); secondApp.setApplicationKey(UUID.fromString("550e8400-e29b-11d4-a716-446655440000")); entityManager.persist(secondApp); beacon = new Beacon(); beacon.setDateCreated(new DateTime()); beacon.setDateUpdated(new DateTime()); beacon.setName("Testbeacon"); beacon.setUuid(UUID.fromString("550e8400-e29b-11d4-a716-446655440002")); beacon.setMajor(1); beacon.setMinor(2); entityManager.persist(beacon); event = new NotificationEvent(); event.setDateCreated(new DateTime()); event.setDateUpdated(new DateTime()); event.setName("Testevent"); event.setMessage("test"); event.setTitle("testtitle"); event.getApps().add(app); event.getBeacons().add(beacon); entityManager.persist(event); EntityDeletionLog deletionLog = new EntityDeletionLog(); deletionLog.setType(event.getClass()); deletionLog.setDateTime(new DateTime()); deletionLog.setEntityId(event.getId()); entityManager.persist(deletionLog); deletionLog = new EntityDeletionLog(); deletionLog.setType(event.getClass()); deletionLog.setDateTime(new DateTime()); deletionLog.setEntityId(3L); entityManager.persist(deletionLog); RemovedRelationshipLog arLog = new RemovedRelationshipLog(); arLog.setAppId(app.getId()); arLog.setEventId(2L); arLog.setDateTime(new DateTime()); entityManager.persist(arLog); arLog = new RemovedRelationshipLog(); arLog.setAppId(app.getId()); arLog.setEventId(3L); arLog.setDateTime(new DateTime()); entityManager.persist(arLog); entityManager.flush(); }
From source file:com.kolich.havalo.client.api.RepositoryTest.java
@Test public void deleteAdminRepository() throws Exception { // Attempt to delete the "admin" repository, should fail. final Either<HttpFailure, Integer> delete = client_.deleteRepository(UUID.fromString(apiKey_)); assertFalse("Uh, successfully deleted admin repository?", delete.success()); // Validate that the API called failed in the "right way". if (!delete.success()) { assertTrue("Expected a 403 Forbidden when deleting admin " + "repository, but got: " + delete.left().getStatusCode(), delete.left().getStatusCode() == SC_FORBIDDEN); }//from w w w .jav a 2 s .c o m }
From source file:fr.msch.wissl.server.TestLogin.java
@Test public void test() throws IOException, JSONException { HttpClient client = new HttpClient(); // good username, bad password: error 401 PostMethod post = new PostMethod(TServer.URL + "login"); post.addParameter("username", admin_username); post.addParameter("password", "bad_password"); client.executeMethod(post);//from w w w. ja v a 2s.c o m post.getResponseBodyAsString(); Assert.assertEquals(401, post.getStatusCode()); // empty password and username: error 401 post = new PostMethod(TServer.URL + "login"); post.addParameter("username", ""); post.addParameter("password", ""); client.executeMethod(post); post.getResponseBodyAsString(); Assert.assertEquals(401, post.getStatusCode()); // log in as admin post = new PostMethod(TServer.URL + "login"); post.addParameter("username", admin_username); post.addParameter("password", admin_password); client.executeMethod(post); String ret = post.getResponseBodyAsString(); JSONObject obj = new JSONObject(ret); int uid_admin = obj.getInt("userId"); String sid_admin = obj.getString("sessionId"); int auth = obj.getInt("auth"); Assert.assertEquals(200, post.getStatusCode()); Assert.assertEquals(uid_admin, this.admin_userId); Assert.assertNotNull(UUID.fromString(sid_admin)); Assert.assertEquals(auth, 1); // call 'stats' with this session, should succeed GetMethod get = new GetMethod(TServer.URL + "stats"); get.addRequestHeader("sessionId", sid_admin); client.executeMethod(get); Assert.assertEquals(200, get.getStatusCode()); // the previous session that was setup by the test case // for this user should NOT have been destroyed // both sessions are kept for the same user get = new GetMethod(TServer.URL + "stats"); get.addRequestHeader("sessionId", this.admin_sessionId); client.executeMethod(get); Assert.assertEquals(200, get.getStatusCode()); // the other user set up by the test case should still be logged in get = new GetMethod(TServer.URL + "stats"); get.addRequestHeader("sessionId", this.user_sessionId); client.executeMethod(get); Assert.assertEquals(200, get.getStatusCode()); // logout all users post = new PostMethod(TServer.URL + "logout"); post.addRequestHeader("sessionId", sid_admin); client.executeMethod(post); Assert.assertEquals(204, post.getStatusCode()); post = new PostMethod(TServer.URL + "logout"); post.addRequestHeader("sessionId", this.user_sessionId); client.executeMethod(post); Assert.assertEquals(204, post.getStatusCode()); post = new PostMethod(TServer.URL + "logout"); post.addRequestHeader("sessionId", this.admin_sessionId); client.executeMethod(post); Assert.assertEquals(204, post.getStatusCode()); // check that neither client can call 'stats' get = new GetMethod(TServer.URL + "stats"); get.addRequestHeader("sessionId", sid_admin); client.executeMethod(get); Assert.assertEquals(401, get.getStatusCode()); get = new GetMethod(TServer.URL + "stats"); get.addRequestHeader("sessionId", this.user_sessionId); client.executeMethod(get); Assert.assertEquals(401, get.getStatusCode()); }
From source file:com.dynatrace.cf.servicebroker.catalog.CatalogFactory.java
@Bean Catalog catalog(@Value("${DYNATRACE_SERVICE_PLANS}") String dynatracePlans) throws Exception { System.out.println("DYNATRACE_SERVICE_PLANS set to: " + dynatracePlans); String serviceId = UUID.nameUUIDFromBytes("Dynatrace_ServiceId_v12".getBytes()).toString(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); plans = (Map) objectMapper.readValue(dynatracePlans, objectMapper.getTypeFactory() .constructMapLikeType(HashMap.class, String.class, DynatracePlan.class)); for (DynatracePlan p : plans.values()) { p.setPlanId();//w ww . j a v a 2 s. c om System.out.println("\t\tDynatracePlan: " + p); } return new Catalog().service().id(UUID.fromString(serviceId)).name("dynatrace").description( "Dynatrace is all-in-one full stack performance monitoring and management powered by artificial intelligence") .bindable(Boolean.valueOf(true)) .tags(new String[] { "dynatrace", "performance", "monitoring", "apm", "analytics" }).metadata() .displayName("Dynatrace") .imageUrl( URI.create("https://assets.dynatrace.com/global/resources/Signet_Logo_RGB_CP_48x48px.png")) .longDescription("Dynatrace is all-in-one full stack performance " + "monitoring and management powered by artificial " + "intelligence that provides you with automated application-health " + "and root-cause analysis information to quickly identify " + "performance bottlenecks in browsers, databases and code.") .providerDisplayName("Dynatrace LLC").documentationUrl(URI.create("https://help.dynatrace.com")) .supportUrl(URI.create("https://support.ruxit.com")).and().addAllPlans(plans).and(); }
From source file:edu.purdue.cybercenter.dm.service.VocabularyService.java
private void fixTerms(Vocabulary vocabulary) { // to be compatible to the old way of storing terms if (vocabulary != null && vocabulary.getTerms().getTerm().isEmpty()) { UUID uuid = UUID.fromString(vocabulary.getUuid()); UUID versionNumber = UUID.fromString(vocabulary.getVersion()); edu.purdue.cybercenter.dm.domain.Vocabulary dbVocabulary = findByUuidAndVersion(uuid, versionNumber); List<edu.purdue.cybercenter.dm.domain.Term> dbTerms = dbVocabulary.getTerms(); vocabulary.getTerms().getTerm().addAll(termService.dbTermsToTerms(dbTerms)); }//from w w w . j a va 2s .c om }
From source file:io.sidecar.event.EventJsonValidationTest.java
@Test(description = "Assert that an event json object can be created when the following mandatory fields are valid") public void eventIsCreatedWithAllMandatoryFields() throws Exception { Event event = mapper.readValue(validEventAsJsonString, Event.class); assertEquals(event.getId(), UUID.fromString(eventAsObjectNode.path("id").textValue())); assertEquals(event.getDeviceId(), eventAsObjectNode.path("deviceId").textValue()); assertEquals(event.getStream(), eventAsObjectNode.path("stream").asText()); assertTrue(event.getTimestamp().isEqual(new DateTime(eventAsObjectNode.path("ts").textValue()))); Set<String> tags = tagsJsonArrayToSet(); assertEquals(event.getTags(), tags); List<Reading> readings = Lists.newArrayList( Iterables.transform(eventAsObjectNode.path("readings"), new Function<JsonNode, Reading>() { @Override// w w w. ja v a2s. c o m public Reading apply(JsonNode input) { return readingFromJsonNode(input); } })); assertEquals(event.getReadings(), readings); }