package com.lingniu.ingest.eventhistory;

import org.junit.jupiter.api.Test;

import java.util.Map;

import static java.util.stream.Collectors.toMap;
import static org.assertj.core.api.Assertions.assertThat;

class Gb32960FieldDictionaryTest {

    @Test
    void vehicleRunningModeIncludesProtocolValueMappings() {
        Gb32960FieldDictionary.Field runningMode = Gb32960FieldDictionary.packets().stream()
                .filter(packet -> packet.code().equals("VEHICLE"))
                .flatMap(packet -> packet.fields().stream())
                .filter(field -> field.key().equals("runningMode"))
                .findFirst()
                .orElseThrow();

        Map<String, String> namesByCode = runningMode.valueMappings().stream()
                .collect(toMap(Gb32960FieldDictionary.ValueMapping::code,
                        Gb32960FieldDictionary.ValueMapping::nameZh));

        assertThat(namesByCode)
                .containsEntry("01", "纯电")
                .containsEntry("02", "混合动力")
                .containsEntry("03", "燃料电池");
    }
}
