package com.neatorobotics.sdk.android.utils;

import android.test.suitebuilder.annotation.SmallTest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertTrue;

@RunWith(MockitoJUnitRunner.class)
@SmallTest
public class StringUtilsUnitTest {
    @Test
    public void testStringToHex() throws Exception{
        String input = "Caffeine";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase("4361666665696e65"));

        input = "email@example.com";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase("656d61696c406578616d706c652e636f6d"));

        input = "città";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase("63697474C3A0"));

        input = "{\"nome\":\"valore\"}";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase("7b226e6f6d65223a2276616c6f7265227d"));

        input = "";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase(""));

        input = " ";
        assertTrue(StringUtils.toHex(input.getBytes("UTF-8")).equalsIgnoreCase("20"));
    }
}

@@ -210,42 +210,158 @@
 ort 
-static org.junit.Assert.assertTrue
+java.io.ByteArrayInputStream;%0Aimport java.nio.charset.Charset;%0A%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.junit.Assert.assertEquals
 ;%0A%0A@
@@ -1299,11 +1299,373 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testGetStringFromInputStream() throws Exception%7B%0A        String input = %22%7B%5C%22name%5C%22:%5C%22marco%C3%A0.,.,.,!$%25&%E2%82%AC%5C%22%7D%22;%0A        ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(Charset.forName(%22UTF-8%22)));%0A        String outputString = StringUtils.getStringFromInputStream(bais);%0A        assertEquals(input, outputString);%0A    %7D
 %0A%7D%0A

Add string utils unit tests.