Package net.sf.uadetector.json.internal.data.serializer

Examples of net.sf.uadetector.json.internal.data.serializer.Serialization


   * URL to retrieve the version of the UAS data
   */
  private static final URL VERSION_URL = JsonDataCreator.class.getClassLoader().getResource("samples/uas.version");

  public static void createOrUpdate(final DataStore store) throws IOException {
    final Serialization serialization = JsonConverter.serialize(store.getData(), SerDeOption.PRETTY_PRINTING);
    final String json = serialization.getJson();

    // get resources directory
    final File resourcesDir = new File(ClassLoader.getSystemResource(".").getPath() + "../../src/test/resources");
    Check.stateIsTrue(resourcesDir.exists(), "the specified resources directory must be available");

View Full Code Here


  @Test
  public void testConversionViceVersa() throws IOException, URISyntaxException {
    final SerDeOption options = SerDeOption.PRETTY_PRINTING;
    final DataStore store = TestDataStoreFactory.produce();
    Serialization serialization = JsonConverter.serialize(store.getData(), options);
    assertThat(serialization.getWarnings()).isEmpty();
    final String json = serialization.getJson();
    final Data parsedData = JsonConverter.deserialize(json).getData();

    // can not be equals, because the IDs are different
    assertThat(store.getData().equals(parsedData)).isFalse();

    // must be equals, because the IDs are identical after conversion
    Serialization serialization2 = JsonConverter.serialize(store.getData(), options);
    assertThat(serialization2.getWarnings()).isEmpty();
    final String expectedJson = serialization2.getJson();
    final Data expectedData = JsonConverter.deserialize(expectedJson).getData();
    assertThat(json).isEqualTo(expectedJson);
    assertThat(parsedData).isEqualTo(expectedData);

    // print some JSON
View Full Code Here

TOP

Related Classes of net.sf.uadetector.json.internal.data.serializer.Serialization

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.