/*
 * Copyright 2012 adrian.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aegee.runanddine.pathfinder;

import org.aegee.runanddine.pathfinder.DistanceMatrix;
import org.aegee.runanddine.pathfinder.DistanceMatrixEntry;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author adrian
 */
public class DistanceMatrixTest {

    private DistanceMatrix instance;
    private int n;

    public DistanceMatrixTest() {
        n = 12;
        DistanceMatrixEntry[][] entries = new DistanceMatrixEntry[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                entries[i][j] = new DistanceMatrixEntry();
                entries[j][i] = new DistanceMatrixEntry();
                entries[i][j].setId1(i);
                entries[i][j].setId2(j);
                entries[j][i].setId1(j);
                entries[j][i].setId2(i);
                entries[i][j].setDistance(Integer.toString(i+j)+".0 km");
                entries[j][i].setDistance(Integer.toString(i+j)+".0 km");
                entries[i][j].setDuration(String.format("%s", i + j));
                entries[j][i].setDuration(String.format("%s", i + j));
            }
        }
        instance = new DistanceMatrix(entries);
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getDistance method, of class DistanceMatrix.
     */
    @Test
    public void testGetDistance_int_int() {
        System.out.println("getDistance");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                assertEquals(i + j, instance.getDistance(i, j), 0.0);
            }
        }
    }

    /**
     * Test of getDuration method, of class DistanceMatrix.
     */
    @Test
    public void testGetDuration_int_int() {
        System.out.println("getDuration");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                assertEquals(String.format("%s", i + j), instance.getDuration(i, j));
            }
        }
    }
}
