// Path: here-oauth-client/src/main/java/com/here/account/util/JacksonSerializer.java
// public class JacksonSerializer implements Serializer {
// 
//     public JacksonSerializer() {
//     }
//     
//     /**
//      * {@inheritDoc}
//      */
//     public Map<String, Object> jsonToMap(InputStream jsonInputStream) {
//         try {
//             return JsonSerializer.toMap(jsonInputStream);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble deserializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public <T> T jsonToPojo(InputStream jsonInputStream, Class<T> pojoClass) {
//         try {
//             return JsonSerializer.toPojo(jsonInputStream, pojoClass);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble deserializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public String objectToJson(Object object) {
//         try {
//             return JsonSerializer.objectToJson(object);
//         } catch (JsonProcessingException e) {
//             throw new RuntimeException("trouble serializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public void writeObjectToJson(OutputStream outputStream, Object object) {
//         try {
//             JsonSerializer.writeObjectToJson(outputStream, object);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble serializing json: " + e, e);
//         }
//     }
//     
// 
// }
// 
// Path: here-oauth-client/src/main/java/com/here/account/util/Serializer.java
// public interface Serializer {
//     
//     /**
//      * Reads from the input jsonInputStream containing bytes from a JSON stream, 
//      * and returns the corresponding Map&lt;String, Object&gt;.
//      * 
//      * @param jsonInputStream the input stream
//      * @return the corresponding deserialized Map&lt;String, Object&gt;
//      */
//     Map<String, Object> jsonToMap(InputStream jsonInputStream);
//     
//     <T> T jsonToPojo (InputStream jsonInputStream, Class<T> pojoClass);
//     
//     String objectToJson(Object object);
//     
//     void writeObjectToJson(OutputStream outputStream, Object object);
// 
// }


import static org.junit.Assert.assertTrue;
import com.here.account.util.JacksonSerializer;
import com.here.account.util.Serializer;
import org.junit.Test;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

    /**
     * Tests the timestamp and relative timings for a FileAccessTokenResponse,
     * when read multiple times from the same previously-serialized file,
     * over increasing clock time.
     *
     * @throws IOException if IO trouble
     * @throws InterruptedException if interrupted during sleep
     */
    @Test
    public void test_timings_sameFile_multipleReads() throws IOException, InterruptedException {
        String accessToken = "my-access-token";
        String tokenType = "bearer";
        Long expiresIn = 45L;
        String refreshToken = null;
        String idToken = null;

        Long exp = (System.currentTimeMillis() / 1000L) + expiresIn;
        String expectedScope = null;

        response = new FileAccessTokenResponse(accessToken,
                tokenType,
                expiresIn, refreshToken, idToken,
                exp, expectedScope);

        long startTimeMillis = response.getStartTimeMilliseconds();

        tmpFile = File.createTempFile("access_token", ".json");
        tmpFile.deleteOnExit();

// Path: here-oauth-client/src/main/java/com/here/account/util/JacksonSerializer.java
// public class JacksonSerializer implements Serializer {
// 
//     public JacksonSerializer() {
//     }
//     
//     /**
//      * {@inheritDoc}
//      */
//     public Map<String, Object> jsonToMap(InputStream jsonInputStream) {
//         try {
//             return JsonSerializer.toMap(jsonInputStream);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble deserializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public <T> T jsonToPojo(InputStream jsonInputStream, Class<T> pojoClass) {
//         try {
//             return JsonSerializer.toPojo(jsonInputStream, pojoClass);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble deserializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public String objectToJson(Object object) {
//         try {
//             return JsonSerializer.objectToJson(object);
//         } catch (JsonProcessingException e) {
//             throw new RuntimeException("trouble serializing json: " + e, e);
//         }
//     }
// 
//     @Override
//     public void writeObjectToJson(OutputStream outputStream, Object object) {
//         try {
//             JsonSerializer.writeObjectToJson(outputStream, object);
//         } catch (IOException e) {
//             throw new RuntimeException("trouble serializing json: " + e, e);
//         }
//     }
//     
// 
// }
// 
// Path: here-oauth-client/src/main/java/com/here/account/util/Serializer.java
// public interface Serializer {
//     
//     /**
//      * Reads from the input jsonInputStream containing bytes from a JSON stream, 
//      * and returns the corresponding Map&lt;String, Object&gt;.
//      * 
//      * @param jsonInputStream the input stream
//      * @return the corresponding deserialized Map&lt;String, Object&gt;
//      */
//     Map<String, Object> jsonToMap(InputStream jsonInputStream);
//     
//     <T> T jsonToPojo (InputStream jsonInputStream, Class<T> pojoClass);
//     
//     String objectToJson(Object object);
//     
//     void writeObjectToJson(OutputStream outputStream, Object object);
// 
// }


// Path: here-oauth-client/src/test/java/com/here/account/oauth2/FileAccessTokenResponseTest.java
import static org.junit.Assert.assertTrue;
import com.here.account.util.JacksonSerializer;
import com.here.account.util.Serializer;
import org.junit.Test;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;


    /**
     * Tests the timestamp and relative timings for a FileAccessTokenResponse,
     * when read multiple times from the same previously-serialized file,
     * over increasing clock time.
     *
     * @throws IOException if IO trouble
     * @throws InterruptedException if interrupted during sleep
     */
    @Test
    public void test_timings_sameFile_multipleReads() throws IOException, InterruptedException {
        String accessToken = "my-access-token";
        String tokenType = "bearer";
        Long expiresIn = 45L;
        String refreshToken = null;
        String idToken = null;

        Long exp = (System.currentTimeMillis() / 1000L) + expiresIn;
        String expectedScope = null;

        response = new FileAccessTokenResponse(accessToken,
                tokenType,
                expiresIn, refreshToken, idToken,
                exp, expectedScope);

        long startTimeMillis = response.getStartTimeMilliseconds();

        tmpFile = File.createTempFile("access_token", ".json");
        tmpFile.deleteOnExit();

        serializer = new JacksonSerializer();