<commit_before>package nl.sikken.bertrik.hab.lorawan;

import java.io.IOException;
import java.io.InputStream;

import org.junit.Assert;
import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;

import nl.sikken.bertrik.hab.lorawan.HeliumUplinkMessage.HotSpot;

public final class HeliumUplinkMessageTest {

    @Test
    public void testDecode() throws IOException {
        // decode JSON
        try (InputStream is = this.getClass().getResourceAsStream("/helium_uplink.json")) {
            ObjectMapper mapper = new ObjectMapper();
            HeliumUplinkMessage uplink = mapper.readValue(is, HeliumUplinkMessage.class);
            Assert.assertNotNull(uplink);

            Assert.assertEquals("6081F9D16837130E", uplink.appEui);
            Assert.assertEquals(0, uplink.fcnt);
            Assert.assertEquals("kissmapper", uplink.name);
            Assert.assertEquals(1, uplink.port);
            Assert.assertEquals(1631457565832L, uplink.reportedAt);
            Assert.assertArrayEquals(new byte[] { 3 }, uplink.payload);

            HotSpot hotSpot = uplink.hotSpots.get(0);
            Assert.assertEquals(52.01745, hotSpot.latitude, 0.00001);
            Assert.assertEquals(4.729876, hotSpot.longitude, 0.00001);
            Assert.assertEquals("melted-quartz-antelope", hotSpot.name);
            Assert.assertEquals(-120, hotSpot.rssi, 0.1);
            Assert.assertEquals(-7.5, hotSpot.snr, 0.1);
        }

    }

}<commit_msg>Verify decoded helium message in unit test.<commit_after>package nl.sikken.bertrik.hab.lorawan;

import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;

import org.junit.Assert;
import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;

import nl.sikken.bertrik.hab.lorawan.HeliumUplinkMessage.HotSpot;

public final class HeliumUplinkMessageTest {

    @Test
    public void testDecode() throws IOException {
        HeliumUplinkMessage helium;

        // decode JSON
        try (InputStream is = this.getClass().getResourceAsStream("/helium_uplink.json")) {
            ObjectMapper mapper = new ObjectMapper();
            helium = mapper.readValue(is, HeliumUplinkMessage.class);
        }
        Assert.assertNotNull(helium);

        Assert.assertEquals("6081F9D16837130E", helium.appEui);
        Assert.assertEquals(0, helium.fcnt);
        Assert.assertEquals("kissmapper", helium.name);
        Assert.assertEquals(1, helium.port);
        Assert.assertEquals(1631457565832L, helium.reportedAt);
        Assert.assertArrayEquals(new byte[] { 3 }, helium.payload);

        HotSpot hotSpot = helium.hotSpots.get(0);
        Assert.assertEquals(52.01745, hotSpot.latitude, 0.00001);
        Assert.assertEquals(4.729876, hotSpot.longitude, 0.00001);
        Assert.assertEquals("melted-quartz-antelope", hotSpot.name);
        Assert.assertEquals(-120, hotSpot.rssi, 0.1);
        Assert.assertEquals(-7.5, hotSpot.snr, 0.1);
        
        // decode to LoRaWAN message
        LoraWanUplinkMessage lorawan = helium.toUplinkMessage();
        Assert.assertEquals(Instant.parse("2021-09-12T14:39:25.832Z"), lorawan.getTime());
        Assert.assertEquals("6081F9D16837130E", lorawan.getAppId());
        Assert.assertEquals("kissmapper", lorawan.getDevId());
        Assert.assertEquals(0, lorawan.getCounter());
        Assert.assertEquals(1, lorawan.getPort());
        Assert.assertArrayEquals(new byte[] {3}, lorawan.getPayloadRaw());
    }

}
{'fraction_non_alphanumeric': 0.11917098445595854, 'fraction_numerical': 0.04691997697179044, 'mean_word_length': 3.1766826923076925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '380399', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1067, 'n_words': 170}