/*
 * Copyright 2020 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * 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 com.b2international.snowowl.core.uri;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * @since 7.12.0
 */
public class ComponentURITest {

	@Test
	public void constructorTest() {
		final String branchPath = "SNOMEDCT/2019-09-30/SNOMEDCT-SE/2020-07-30/SNOMEDCT-EXT";
		final CodeSystemURI uri = new CodeSystemURI(branchPath);
		short terminologyComponentId = 150;
		final String componentId = "123456789";
		ComponentURI componentURI = ComponentURI.of(uri, terminologyComponentId, componentId);
		assertEquals(componentURI.codeSystem(), ComponentURI.SLASH_SPLITTER.split(branchPath).iterator().next());
		assertEquals(componentURI.terminologyComponentId(), terminologyComponentId);
		assertEquals(componentURI.identifier(), componentId);
	}
	
	@Test
	public void serializationTest() {
		final String uri = "LCS1/1542/750/SO";
		ComponentURI componentURI = ComponentURI.of(uri);
		assertEquals(componentURI.codeSystem(), "LCS1");
		assertEquals(componentURI.terminologyComponentId(), "750");
		assertEquals(componentURI.identifier(), "SO");
	}
	
}

@@ -733,16 +733,84 @@
 .Test;%0A%0A
+import com.b2international.commons.exceptions.BadRequestException;%0A%0A
 /**%0A * @
@@ -1706,13 +1706,11 @@
 (), 
-%22
 750
-%22
 );%0A%09
@@ -1762,10 +1762,554 @@
 );%0A%09%7D%0A%09%0A
+%09@Test(expected = IllegalArgumentException.class)%0A%09public void numberOfPartsTest() %7B%0A%09%09final String incompleteURI = %22LCS1/1542%22;%0A%09%09ComponentURI.of(incompleteURI); //Attempt to parse incomplete component URI%0A%09%7D%0A%09%0A%09@Test(expected = BadRequestException.class)%0A%09public void missingCodeSystemTest() %7B%0A%09%09final String malformedURI = %22/750/1542%22;%0A%09%09ComponentURI.of(malformedURI);%0A%09%7D%0A%09%0A%09@Test(expected = NumberFormatException.class)%0A%09public void incorrectTerminologyComponentIdTest() %7B%0A%09%09final String uri = %22LCS1/xyz/1542%22;%0A%09%09ComponentURI.of(uri);%0A%09%7D%0A%09%0A
 %7D%0A

Add further componentURI parse tests