/*******************************************************************************
 * Copyright 2017 xlate.io LLC, http://www.xlate.io
 *
 * 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 io.xlate.edi.schema;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;

@SuppressWarnings({ "resource" })
public class StaEDISchemaTest {

	@Test(expected = NullPointerException.class)
	public void testSetTypesNullTypes() throws EDISchemaException {
		StaEDISchema schema = new StaEDISchema();
		schema.setTypes(null);
	}

	@Test
	public void testRootTypeIsLoop() throws EDISchemaException, IOException {
		StaEDISchema schema = new StaEDISchema();
		InputStream schemaStream =
				SchemaUtils.getStreams("X12/00402/control-schema.xml")
				.nextElement().openStream();
		Map<String, EDIType> types =
				StaEDISchemaFactory.loadTypes(schemaStream);
		schema.setTypes(types);

		Assert.assertEquals(
				EDIType.TYPE_LOOP,
				schema.getType(StaEDISchema.MAIN).getTypeCode());
	}
}

@@ -263,17 +263,16 @@
 License.
- 
  You may
@@ -289,14 +289,14 @@
 copy
+ of
 %0A *
- of
  the
@@ -312,18 +312,16 @@
 at%0A *%0A *
-  
  http://
@@ -574,17 +574,16 @@
 implied.
- 
  See the
@@ -986,17 +986,20 @@
 Test %7B%0A%0A
-%09
+    
 @Test(ex
@@ -1035,17 +1035,20 @@
 .class)%0A
-%09
+    
 public v
@@ -1095,34 +1095,40 @@
 hemaException %7B%0A
-%09%09
+        
 StaEDISchema sch
@@ -1153,18 +1153,24 @@
 hema();%0A
-%09%09
+        
 schema.s
@@ -1188,20 +1188,29 @@
 l);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Test%0A
-%09
+    
 publ
@@ -1279,18 +1279,24 @@
 ption %7B%0A
-%09%09
+        
 StaEDISc
@@ -1329,18 +1329,24 @@
 hema();%0A
-%09%09
+        
 InputStr
@@ -1363,21 +1363,17 @@
 Stream =
-%0A%09%09%09%09
+ 
 SchemaUt
@@ -1396,53 +1396,128 @@
 X12/
+v
 00402
-/control-schema.xml%22)%0A%09%09%09%09.nextElement()
+.xml%22)%0A                                              .nextElement()%0A                                              
 .ope
@@ -1527,18 +1527,24 @@
 ream();%0A
-%09%09
+        
 Map%3CStri
@@ -1563,21 +1563,17 @@
  types =
-%0A%09%09%09%09
+ 
 StaEDISc
@@ -1609,18 +1609,24 @@
 tream);%0A
-%09%09
+        
 schema.s
@@ -1642,18 +1642,24 @@
 ypes);%0A%0A
-%09%09
+        
 Assert.a
@@ -1670,21 +1670,16 @@
 tEquals(
-%0A%09%09%09%09
 EDIType.
@@ -1693,12 +1693,36 @@
 OP,%0A
-%09%09%09%09
+                            
 sche
@@ -1771,9 +1771,12 @@
 ));%0A
-%09
+    
 %7D%0A%7D%0A

Correct file path in unit test