package eu.dnetlib.enabling.aas.nh.finder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.net.URI;
import java.net.URISyntaxException;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import eu.dnetlib.enabling.aas.finder.modules.SecProfileAttrFM;
import eu.dnetlib.enabling.aas.secprof.ProfileIdentifierLocation;


public class SecProfileAttrFMTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testParseFieldLocation() throws URISyntaxException {
		URI sourceURI = new URI("");
		assertNull(SecProfileAttrFM.parseFieldLocation(sourceURI));
		assertNull(SecProfileAttrFM.parseFieldLocation(null));
		String profileKind = "UserDSResources";
		String profileType = "UserDSResourceType";
		String conditionField = "RESOURCE_PROFILE/BODY/CONFIGURATION/PERSONAL_INFO/EMAIL/@value";
		char delimiter = ':';
		StringBuffer strBuff = new StringBuffer();
		strBuff.append(profileKind);
		strBuff.append(delimiter);
		strBuff.append(profileType);
		strBuff.append(delimiter);
		strBuff.append(conditionField);
		ProfileIdentifierLocation loc = SecProfileAttrFM.parseFieldLocation(new URI(strBuff.toString()));
		assertNotNull(loc);
		assertEquals(profileKind,loc.getProfileKind());
		assertEquals(profileType,loc.getProfileType());
		assertEquals(conditionField,loc.getPath());
	}

}
