package com.github.javadev.nazk.client;

import java.util.Map;
import com.github.underscore.lodash.$;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class HttpClientTest {
    private static NazkClient client = HttpClient.createDefault();

    @Test
    public void getDeclarations() {
        Map<String, Object> declarations = client.getDeclarations("");
        assertEquals("1", $.get(declarations, "page.currentPage").toString());
        assertEquals("400", $.get(declarations, "page.batchSize").toString());
    }

    @Test
    public void getDeclaration() {
        Map<String, Object> declaration = client.getDeclaration("043c6b5d-a470-4fb0-bc3b-3332af7fe10e");
        assertEquals("1", $.get(declaration, "data.step_0.declarationType").toString());
        assertEquals("Люстдорфська дорога", $.get(declaration, "data.step_1.street").toString());
    }

    @Test
    public void getDeclarationHtml() {
        String declaration = client.getDeclarationHtml("043c6b5d-a470-4fb0-bc3b-3332af7fe10e");
        assertTrue(declaration.startsWith("<!DOCTYPE html><html lang=\"en\"><head> "
        + "<meta charset=\"utf-8\"> <title>Перегляд декларації"));
    }

    @Test
    public void main() {
        HttpClient.main("test");
    }
}

@@ -1170,16 +1170,20 @@
         
+    
 + %22%3Cmeta
@@ -1232,32 +1232,284 @@
 %D0%B0%D1%86%D1%96%D1%97%22));%0A    %7D%0A%0A
+    @Test%0A    public void getDeclarationPdf() %7B%0A        byte%5B%5D data = $.fetch(%22https://public.nazk.gov.ua/storage/documents/pdf/%22%0A            + %225/0/e/e/50ee7eae-f4ee-4b5c-b67d-9917154f7c53.pdf%22).blob();%0A        assertTrue(data.length %3E 10000);%0A    %7D%0A%0A
     @Test%0A    pu

Add test to read pdf.