<commit_before>package org.openweathermap.api.gson

import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import spock.lang.Specification


class MillisecondsDateTypeAdapterSpockTest extends Specification {
    MillisecondsDateTypeAdapter adapter = new MillisecondsDateTypeAdapter()

    def "should write Date into JsonWriter as long"() {
        given:
        def jsonWriter = Mock(JsonWriter)
        def date = new Date(116, 5, 5)
        when:
        adapter.write(jsonWriter, date)
        then:
        1 * jsonWriter.value(1465074000000L);
    }

    def "should write null into JsonWriter when date is null"() {
        given:
        def jsonWriter = Mock(JsonWriter)
        def date = null
        when:
        adapter.write(jsonWriter, date)
        then:
        1 * jsonWriter.nullValue();
    }

    def "should return null when reading null from JsonReader"() {
        given:
        def jsonReader = Mock(JsonReader)
        when:
        def actual = adapter.read(jsonReader)
        then:
        1 * jsonReader.peek() >> JsonToken.NULL
        1 * jsonReader.nextNull()
        actual == null
    }

    def "should return Date when reading milliseconds from JsonReader"() {
        given:
        def jsonReader = Mock(JsonReader)
        def expected = new Date(116, 5, 5)
        when:
        def actual = adapter.read(jsonReader)
        then:
        1 * jsonReader.peek() >> JsonToken.NUMBER
        1 * jsonReader.nextLong() >> 1465074000000L
        expected == actual
    }
}<commit_msg>update test to compare millis instead of objects<commit_after>package org.openweathermap.api.gson

import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import spock.lang.Specification


class MillisecondsDateTypeAdapterSpockTest extends Specification {
    MillisecondsDateTypeAdapter adapter = new MillisecondsDateTypeAdapter()

    def "should write Date into JsonWriter as long"() {
        given:
        def jsonWriter = Mock(JsonWriter)
        def date = new Date(116, 5, 5)
        when:
        adapter.write(jsonWriter, date)
        then:
        1 * jsonWriter.value(1465074000000L)
    }

    def "should write null into JsonWriter when date is null"() {
        given:
        def jsonWriter = Mock(JsonWriter)
        def date = null
        when:
        adapter.write(jsonWriter, date)
        then:
        1 * jsonWriter.nullValue();
    }

    def "should return null when reading null from JsonReader"() {
        given:
        def jsonReader = Mock(JsonReader)
        when:
        def actual = adapter.read(jsonReader)
        then:
        1 * jsonReader.peek() >> JsonToken.NULL
        1 * jsonReader.nextNull()
        actual == null
    }

    def "should return Date when reading milliseconds from JsonReader"() {
        given:
        def jsonReader = Mock(JsonReader)
        def timeInMillis = 1465074000000L
        when:
        def actual = adapter.read(jsonReader)
        then:
        1 * jsonReader.peek() >> JsonToken.NUMBER
        1 * jsonReader.nextLong() >> timeInMillis
        actual.getTime() == timeInMillis
    }
}
{'fraction_non_alphanumeric': 0.08496124031007751, 'fraction_numerical': 0.024496124031007753, 'mean_word_length': 2.3957894736842107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3114284', 'n_tokens_mistral': 957, 'n_tokens_neox': 892, 'n_words': 248}