<commit_before>package net.fortuna.ical4j.model

import net.fortuna.ical4j.util.CompatibilityHints
import spock.lang.Ignore
import spock.lang.Specification
import spock.lang.Unroll

import java.time.Duration

class TemporalAmountAdapterTest extends Specification {

    def "verify string representation"() {
        expect:
        new TemporalAmountAdapter(duration) as String == expectedValue

        where:
        duration                    | expectedValue
        Duration.ofHours(4)         | "PT4H"
        Duration.ofHours(-4)         | "-PT4H"
        Duration.ofDays(12)         | "P12D"
        Duration.ofDays(12).plusMinutes(30)     | "P12DT30M"
        Duration.ofDays(12).plusMinutes(-30)    | "P11DT23H30M"
        Duration.ofDays(-12).plusMinutes(-30)    | "-P12DT30M"
        java.time.Period.ofDays(12) | "P12D"
        java.time.Period.ofWeeks(7) | "P7W"
        java.time.Period.ofDays(365) | "P365D"
        java.time.Period.ofDays(364) | "P52W"
        java.time.Period.ofYears(1) | "P52W"
        java.time.Period.ofMonths(6) | "P26W"<commit_msg>Modify test case for issue #480 so that results are consistent, whatever the current date is.  Do not rely on the default seed in the TemporalAmountAdapter::toString method because it returns inconsistent results for certain Periods, for example ±6 months.<commit_after>package net.fortuna.ical4j.model

import net.fortuna.ical4j.util.CompatibilityHints
import spock.lang.Ignore
import spock.lang.Specification
import spock.lang.Unroll

import java.time.Duration
import java.time.LocalDateTime

class TemporalAmountAdapterTest extends Specification {

    def "verify string representation"() {
        setup: 'Set default seed date for test consistency'
        def seed = LocalDateTime.parse("2021-04-01T00:00:00")

        expect:
        new TemporalAmountAdapter(duration).toString(seed) == expectedValue

        where:
        duration                    | expectedValue
        Duration.ofHours(4)         | "PT4H"
        Duration.ofHours(-4)         | "-PT4H"
        Duration.ofDays(12)         | "P12D"
        Duration.ofDays(12).plusMinutes(30)     | "P12DT30M"
        Duration.ofDays(12).plusMinutes(-30)    | "P11DT23H30M"
        Duration.ofDays(-12).plusMinutes(-30)    | "-P12DT30M"
        java.time.Period.ofDays(12) | "P12D"
        java.time.Period.ofWeeks(7) | "P7W"
        java.time.Period.ofDays(365) | "P365D"
        java.time.Period.ofDays(364) | "P52W"
        java.time.Period.ofYears(1) | "P52W"
        java.time.Period.ofMonths(6) | "P26W"
{'fraction_non_alphanumeric': 0.11224489795918367, 'fraction_numerical': 0.05337519623233909, 'mean_word_length': 2.699564586357039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1794972', 'n_tokens_mistral': 926, 'n_tokens_neox': 829, 'n_words': 154}