<commit_before>/* 
 * Copyright (C) 2015 <NAME>
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 */
package api.web.gw2.mapping.core;

import api.web.gw2.mapping.v2.account.Account;
import api.web.gw2.mapping.v2.account.bank.BankSlot;
import api.web.gw2.mapping.v2.account.wallet.CurrencyAmount;
import api.web.gw2.mapping.v2.achievements.Achievement;
import api.web.gw2.mapping.v2.achievements.daily.DailyAchievement;
import api.web.gw2.mapping.v2.achievements.daily.DailyAchievementLevelRange;
import api.web.gw2.mapping.v2.characters.Character;
import api.web.gw2.mapping.v2.characters.CharacterCrafting;
import api.web.gw2.mapping.v2.materials.MaterialStorage;
import api.web.gw2.mapping.v2.minis.Mini;
import api.web.gw2.mapping.v2.recipes.RecipeCraftingDiscipline;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import java.util.stream.IntStream;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Unit test.
 * @author <NAME>
 */
public class JsonpContext_LocalTest {

    public JsonpContext_LocalTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    @Test
    public void testLoadObject_Account_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Account local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/account/account1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Account value = instance.loadObject(Account.class, url);
        assertNotNull(value);
        assertEquals("b8169418-1c11-405f-91bb-e2b29d602b8a", value.getId()); // NOI18N.
        assertEquals("ExampleAccount.1234", value.getName()); // NOI18N.
        assertEquals(1007, value.getWorld());
        assertEquals(Collections.unmodifiableSet(new HashSet(Arrays.asList("75FD83CF-0C45-4834-BC4C-097F93A487AF"))), value.getGuilds()); // NOI18N.
    }

    @Test
    public void testLoadObject_CurrencyAmount_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(CurrencyAmount local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/account/wallet/currency_amount1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final CurrencyAmount value = instance.loadObject(CurrencyAmount.class, url);
        assertNotNull(value);
        assertEquals(1, value.getId());
        assertEquals(100001, value.getValue());
    }

    @Test
    public void testLoadObject_Mini_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Mini local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/minis/mini1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Mini value = instance.loadObject(Mini.class, url);
        assertNotNull(value);
        assertEquals(1, value.getId());
        assertEquals("Mini-Rytlock", value.getName()); // NOI18N.
        assertEquals(Optional.empty(), value.getUnlock());
        assertEquals(Optional.of(new URL("https://render.guildwars2.com/file/795ED1B945A29EC3E3066797DF57FFB25ABAA631/340551.png")), value.getIcon()); // NOI18N.
        assertEquals(1, value.getOrder());
        assertEquals(21047, value.getItemId());
    }

    @Test
    public void testLoadObject_Character_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Character local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/characters/character1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Character value = instance.loadObject(Character.class, url);
        assertNotNull(value);
    }

    @Test
    public void testLoadObject_CharacterCrafting_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(CharacterCrafting local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/characters/charactercrafting1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final CharacterCrafting value = instance.loadObject(CharacterCrafting.class, url);
        assertNotNull(value);
        assertEquals(RecipeCraftingDiscipline.ARTIFICER, value.getDiscipline());
        assertEquals(500, value.getRating());
        assertEquals(true, value.isActive());
    }

    @Test
    public void testLoadObject_MaterialStorage_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(MaterialStorage local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/materials/materialstorage1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final MaterialStorage value = instance.loadObject(MaterialStorage.class, url);
        assertNotNull(value);
        assertEquals(38, value.getId());
        assertEquals("Festive Materials", value.getName()); // NOI18N.
        assertEquals(Collections.unmodifiableSet(new HashSet(Arrays.asList(36060, 36061, 36059, 36041, 38130, 38131, 38132, 38133, 38134, 38135, 43319, 47909, 48807, 48805, 48806))), value.getItems());
    }

    @Test
    public void testLoadObject_Achievement_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {<commit_msg>Added base test for v2/characters/equipment.<commit_after>/* 
 * Copyright (C) 2015 <NAME>
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 */
package api.web.gw2.mapping.core;

import api.web.gw2.mapping.v2.account.Account;
import api.web.gw2.mapping.v2.account.bank.BankSlot;
import api.web.gw2.mapping.v2.account.wallet.CurrencyAmount;
import api.web.gw2.mapping.v2.achievements.Achievement;
import api.web.gw2.mapping.v2.achievements.daily.DailyAchievement;
import api.web.gw2.mapping.v2.achievements.daily.DailyAchievementLevelRange;
import api.web.gw2.mapping.v2.characters.Character;
import api.web.gw2.mapping.v2.characters.CharacterCrafting;
import api.web.gw2.mapping.v2.characters.equipment.Equipment;
import api.web.gw2.mapping.v2.materials.MaterialStorage;
import api.web.gw2.mapping.v2.minis.Mini;
import api.web.gw2.mapping.v2.recipes.RecipeCraftingDiscipline;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.IntStream;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Unit test.
 * @author <NAME>
 */
public class JsonpContext_LocalTest {

    public JsonpContext_LocalTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    @Test
    public void testLoadObject_Account_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Account local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/account/account1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Account value = instance.loadObject(Account.class, url);
        assertNotNull(value);
        assertEquals("b8169418-1c11-405f-91bb-e2b29d602b8a", value.getId()); // NOI18N.
        assertEquals("ExampleAccount.1234", value.getName()); // NOI18N.
        assertEquals(1007, value.getWorld());
        assertEquals(Collections.unmodifiableSet(new HashSet(Arrays.asList("75FD83CF-0C45-4834-BC4C-097F93A487AF"))), value.getGuilds()); // NOI18N.
    }

    @Test
    public void testLoadObject_CurrencyAmount_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(CurrencyAmount local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/account/wallet/currency_amount1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final CurrencyAmount value = instance.loadObject(CurrencyAmount.class, url);
        assertNotNull(value);
        assertEquals(1, value.getId());
        assertEquals(100001, value.getValue());
    }

    @Test
    public void testLoadObject_Mini_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Mini local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/minis/mini1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Mini value = instance.loadObject(Mini.class, url);
        assertNotNull(value);
        assertEquals(1, value.getId());
        assertEquals("Mini-Rytlock", value.getName()); // NOI18N.
        assertEquals(Optional.empty(), value.getUnlock());
        assertEquals(Optional.of(new URL("https://render.guildwars2.com/file/795ED1B945A29EC3E3066797DF57FFB25ABAA631/340551.png")), value.getIcon()); // NOI18N.
        assertEquals(1, value.getOrder());
        assertEquals(21047, value.getItemId());
    }

    @Test
    public void testLoadObject_Character_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Character local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/characters/character1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final Character value = instance.loadObject(Character.class, url);
        assertNotNull(value);
    }

    @Test
    public void testLoadObject_CharacterCrafting_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(CharacterCrafting local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/characters/charactercrafting1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final CharacterCrafting value = instance.loadObject(CharacterCrafting.class, url);
        assertNotNull(value);
        assertEquals(RecipeCraftingDiscipline.ARTIFICER, value.getDiscipline());
        assertEquals(500, value.getRating());
        assertEquals(true, value.isActive());
    }

    @Test
    public void testLoadObject_Equipment_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(Equipment local)"); // NOI18N.
        final String basecode = "/api/web/gw2/mapping/v2/characters/equipment/";
        final String[] filenames = {
            "equipment1.json",
            "equipment2.json",
            "equipment3.json",
            "equipment4.json"};
        IntStream.range(0, filenames.length)
                .forEach(index -> {
                    try {
                        final String filename = filenames[index];
                        final URL url = getClass().getResource(basecode + filename); // NOI18N.
                        final JsonpContext instance = JsonpContext.INSTANCE;
                        final Equipment value = instance.loadObject(Equipment.class, url);
                        assertNotNull(value);
                    } catch (NullPointerException | IOException ex) {
                        fail(ex.getMessage());
                    }
                });
    }

    @Test
    public void testLoadObject_MaterialStorage_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        System.out.println("loadObject(MaterialStorage local)"); // NOI18N.
        final URL url = getClass().getResource("/api/web/gw2/mapping/v2/materials/materialstorage1.json"); // NOI18N.
        final JsonpContext instance = JsonpContext.INSTANCE;
        final MaterialStorage value = instance.loadObject(MaterialStorage.class, url);
        assertNotNull(value);
        assertEquals(38, value.getId());
        assertEquals("Festive Materials", value.getName()); // NOI18N.
        assertEquals(Collections.unmodifiableSet(new HashSet(Arrays.asList(36060, 36061, 36059, 36041, 38130, 38131, 38132, 38133, 38134, 38135, 43319, 47909, 48807, 48805, 48806))), value.getItems());
    }

    @Test
    public void testLoadObject_Achievement_Local() throws IOException, InstantiationException, IllegalAccessException, NoSuchFieldException {
{'fraction_non_alphanumeric': 0.11536787113626469, 'fraction_numerical': 0.03816572340734291, 'mean_word_length': 3.645433097404786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 2, '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': '7056767', 'n_tokens_mistral': 4360, 'n_tokens_neox': 4055, 'n_words': 748}