List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:com.nesscomputing.jackson.datatype.TestCustomUuidModule.java
@Test public void testCustomUUIDDeserialization() throws Exception { final UUID orig = UUID.fromString("550e8400-e29b-41d4-a716-446655440000"); final AtomicBoolean called = new AtomicBoolean(false); ObjectMapper mapper = getObjectMapper(new AbstractModule() { @Override/* w ww . j ava 2s . c om*/ protected void configure() { bind(new TypeLiteral<JsonDeserializer<UUID>>() { }).toInstance(new CustomUuidDeserializer() { private static final long serialVersionUID = 1L; @Override protected UUID _deserialize(String value, DeserializationContext ctxt) throws IOException, JsonProcessingException { UUID foo = super._deserialize(value, ctxt); called.set(true); return foo; } }); } }); UUID uuid = mapper.readValue('"' + orig.toString() + '"', new TypeReference<UUID>() { }); Assert.assertEquals(orig, uuid); Assert.assertTrue(called.get()); }
From source file:com.googlecode.deadalus.server.internal.LocalObjectFactoryRegistryTests.java
@Test public void testAddJar() throws IOException, ClassNotFoundException { // create a new registry LocalObjectFactoryRegistry registry = new LocalObjectFactoryRegistry(); // mock the application context /*ApplicationContext parentContext = EasyMock.createMock(ApplicationContext.class); EasyMock.expect(parentContext.getDisplayName()).andReturn("Test Context"); EasyMock.replay(parentContext);*/ registry.setApplicationContext(null); // should all be fine.. now add a jar that is not on the classpath! registry.addJarFile(new File( "/Joost/Development/googlecode.com/deadalus/bomberman/target/bomberman-0.1.0-SNAPSHOT.jar")); // now we should get the bomberman factory ObjectFactory bombFactory = registry .getObjectFactory(UUID.fromString("3d82f2e1-d5c1-376e-8047-a98a395fcf4a")); Assert.assertNotNull(bombFactory);//from ww w . ja v a2 s . c om Assert.assertNotNull(bombFactory.getApplication()); //EasyMock.verify(parentContext); }
From source file:at.alladin.rmbt.db.fields.UUIDField.java
@Override public void setField(final JSONObject obj) { if (jsonKey != null && obj.has(jsonKey)) value = UUID.fromString(obj.optString(jsonKey, null)); }
From source file:at.alladin.rmbt.controlServer.NdtResultResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();/*from w ww. jav a 2 s .c om*/ final JSONObject answer = new JSONObject(); try { final JSONObject request = new JSONObject(entity); // System.out.println(request.toString(4)); final String testUuidString; // TODO remove test_token if (request.has("test_token")) { final String[] token = request.getString("test_token").split("_"); testUuidString = token[0]; } else if (request.has("test_uuid")) { testUuidString = request.getString("test_uuid"); } else throw new IllegalArgumentException(); final Test test = new Test(conn); final UUID testUuid = UUID.fromString(testUuidString); final long testId = test.getTestByUuid(testUuid); if (testId < 0) throw new IllegalArgumentException(); final TestNdt ndt = new TestNdt(conn); ((LongField) ndt.getField("test_id")).setValue(testId); ndt.setFields(request); ndt.storeTest(); } catch (final IllegalArgumentException e) { e.printStackTrace(); } catch (final JSONException e) { e.printStackTrace(); } return answer.toString(); }
From source file:net.sourceforge.msscodefactory.cfcore.v2_1.CFGenKb.CFGenKbSecSessionPKey.java
public CFGenKbSecSessionPKey() { requiredSecSessionId = UUID.fromString(CFGenKbSecSessionBuff.SECSESSIONID_INIT_VALUE.toString()); }
From source file:fm.last.musicbrainz.data.dao.impl.ArtistDaoImplIT.java
@Test public void getByNotExistingGidReturnsNull() { UUID gid = UUID.fromString("b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d"); Artist artist = dao.getByGid(gid);/*from w w w . j a va 2 s . c o m*/ assertThat(artist, is(nullValue())); }
From source file:net.sourceforge.vulcan.spring.jdbc.BuildIdMapQuery.java
@Override protected Object mapRow(ResultSet rs, int rowIndex) throws SQLException { final String name = rs.getString("name"); if (!name.equals(prevName)) { putList();//from w w w . j a v a 2s. c om ids = new ArrayList<UUID>(); prevName = name; } ids.add(UUID.fromString(rs.getString("uuid"))); return null; }
From source file:gr.upatras.ece.nam.baker.BakerClientIT.java
@Test public void testBakerClientInstallServiceNotFoundAndFail() throws Exception { logger.info("Executing TEST = testBakerRSInstallServiceNotFound"); List<Object> providers = new ArrayList<Object>(); providers.add(new org.codehaus.jackson.jaxrs.JacksonJsonProvider()); String uuid = UUID.fromString("55cab8b8-668b-4c75-99a9-39b24ed3d8be").toString(); InstalledBun is = prepareInstalledService(uuid); WebClient client = WebClient.create(endpointUrl + "/services/api/client/ibuns/", providers); Response r = client.accept("application/json").type("application/json").post(is); assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); String bakerAPIVersionListHeaders = (String) r.getHeaders().getFirst("X-Baker-API-Version"); assertEquals("1.0.0", bakerAPIVersionListHeaders); MappingJsonFactory factory = new MappingJsonFactory(); JsonParser parser = factory.createJsonParser((InputStream) r.getEntity()); InstalledBun output = parser.readValueAs(InstalledBun.class); logger.info("InstalledServiceoutput = " + output.getUuid() + ", status=" + output.getStatus()); assertEquals(InstalledBunStatus.INIT, output.getStatus()); // wait for 2 seconds Thread.sleep(2000);// w w w . j av a 2s. c om // ask again about this task client = WebClient.create(endpointUrl + "/services/api/client/ibuns/" + uuid); r = client.accept("application/json").type("application/json").get(); factory = new MappingJsonFactory(); parser = factory.createJsonParser((InputStream) r.getEntity()); output = parser.readValueAs(InstalledBun.class); assertEquals(uuid, output.getUuid()); assertEquals(InstalledBunStatus.FAILED, output.getStatus()); assertEquals("(pending)", output.getName()); }
From source file:org.trustedanalytics.servicecatalog.security.JwtUserDetailsTokenConverter.java
@Override public Authentication extractAuthentication(Map<String, ?> map) { if (!map.containsKey(USERNAME)) { return null; }/*from w w w. ja va 2 s . c o m*/ if (map.containsKey(AUTHORITIES)) { return super.extractAuthentication(map); } if (map.containsKey(SCOPE)) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(map.get(USERNAME), "N/A", getAuthorities(map)); if (map.containsKey(USER_ID)) { AccessTokenDetails details = new AccessTokenDetails(UUID.fromString((String) map.get(USER_ID))); token.setDetails(details); } return token; } return null; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmSecUserHPKey.java
public CFCrmSecUserHPKey() { super(); requiredSecUserId = UUID.fromString(CFCrmSecUserBuff.SECUSERID_INIT_VALUE.toString()); }