/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package it.inaf.oats.vospace.datamodel; import java.util.ArrayList; import java.util.List; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; public class NodeUtilsTest { //@Test public void getPathFromRequestURLStringTest() { String urlForTest = "http://server.example.com/vospace/"; String result = NodeUtils.getPathFromRequestURLString(urlForTest); assertEquals("/", result); urlForTest = "http://server.example.com/vospace/nodes"; result = NodeUtils.getPathFromRequestURLString(urlForTest); assertEquals("/", result); urlForTest = "http://server.example.com/vospace/nodes/mydata"; result = NodeUtils.getPathFromRequestURLString(urlForTest); assertEquals("/mydata", result); urlForTest = "http://server.example.com/vospace/nodes/mydata1/uffi/nonso/pappa.txt"; result = NodeUtils.getPathFromRequestURLString(urlForTest); assertEquals("/mydata1/uffi/nonso/pappa.txt", result); } /* Is it a possible case? @Test public void subPathComponentsTest1() { //assertArrayEquals(expected, actual) String pathForTest = ""; List result = NodeUtils.subPathComponents(pathForTest); List expected = new ArrayList(); // expected empty assertArrayEquals(expected.toArray(), result.toArray()); } */ @Test public void subPathComponentsTest2() { String pathForTest = "/"; List result = NodeUtils.subPathComponents(pathForTest); List expected = new ArrayList(); expected.add("/"); assertArrayEquals(expected.toArray(), result.toArray()); } @Test public void subPathComponentsTest3() { String pathForTest = "/mynode1"; List result = NodeUtils.subPathComponents(pathForTest); List expected = new ArrayList(); expected.add("/mynode1"); assertArrayEquals(expected.toArray(), result.toArray()); } @Test public void subPathComponentsTest4() { //assertArrayEquals(expected, actual) String pathForTest = "/mydata1/uffi/nonso/pappa.txt"; List result = NodeUtils.subPathComponents(pathForTest); List expected = new ArrayList(); expected.add("/mydata1"); expected.add("/mydata1/uffi"); expected.add("/mydata1/uffi/nonso"); expected.add("/mydata1/uffi/nonso/pappa.txt"); assertArrayEquals(expected.toArray(), result.toArray()); } }