package com.gentics.mesh.core.webroot;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.mockito.Mockito;

import com.gentics.mesh.core.data.Branch;

public class PathPrefixUtilTest {

	@Test
	public void testSanitize() {
		assertEquals("", PathPrefixUtil.sanitize(""));
		assertEquals("/bla", PathPrefixUtil.sanitize("bla"));
		assertEquals("/bla", PathPrefixUtil.sanitize("bla/"));
	}

	@Test
	public void testStrip() {
		Branch branch = Mockito.mock(Branch.class);
		when(branch.getPathPrefix()).thenReturn("");
		assertEquals("", PathPrefixUtil.strip(branch, ""));

		when(branch.getPathPrefix()).thenReturn("abc");
		assertEquals("", PathPrefixUtil.strip(branch, ""));
		assertEquals("", PathPrefixUtil.strip(branch, "/abc"));
	}

	@Test
	public void testStartsWithPrefix() {
		Branch branch = Mockito.mock(Branch.class);
		when(branch.getPathPrefix()).thenReturn("cba");
		assertFalse(PathPrefixUtil.startsWithPrefix(branch, "/abc"));

		when(branch.getPathPrefix()).thenReturn("abc");
		assertTrue(PathPrefixUtil.startsWithPrefix(branch, "/abc"));
	}
}

@@ -531,24 +531,74 @@
 e(%22bla/%22));%0A
+%09%09assertEquals(%22%22, PathPrefixUtil.sanitize(%22/%22));%0A
 %09%7D%0A%0A%09@Test%0A%09

Add extra assertion