<commit_before>/************************************************************************
 * Copyright © 2007-2017 - General Electric Company, All Rights Reserved
 * 
 * Project: SADL
 * 
 * Description: The Semantic Application Design Language (SADL) is a
 * language for building semantic models and expressing rules that
 * capture additional domain knowledge. The SADL-IDE (integrated
 * development environment) is a set of Eclipse plug-ins that
 * support the editing and testing of semantic models using the
 * SADL language.
 * 
 * This software is distributed "AS-IS" without ANY WARRANTIES
 * and licensed under the Eclipse Public License - v 1.0
 * which is available at http://www.eclipse.org/org/documents/epl-v10.php
 * 
 ***********************************************************************/
package com.ge.research.sadl.ui.tests.contentassist

import com.ge.research.sadl.model.DeclarationExtensions
import com.google.common.collect.Iterables
import org.junit.Test

import static com.ge.research.sadl.processing.ISadlOntologyHelper.ContextBuilder.*
import static com.ge.research.sadl.processing.ISadlOntologyHelper.GrammarContextIds.*
import static org.junit.Assert.*

/**
 * Test for transforming Eclipse-based content assist contexts into ontology helper contexts.
 * 
 * @author akos.kitta
 */
class SadlOntologyContextTest extends AbstractSadlContentAssistTest {

	@Test
	def void checkPropertyInitializerValueWithRestrictions() {
		val context = newBuilder('''
		uri "http://myUri". 
		Foo is a class described by p1 with values of type Foo. 
		myFoo is a Foo with p1 ''').ontologyContext;

		assertNotNull(context);
		assertNotEquals(MISSING_SUBJECT, context.subject);
		assertTrue(context.grammarContextId.present);
		assertEquals(SADLPROPERTYINITIALIZER_VALUE, context.grammarContextId.get);
		assertEquals(1, Iterables.size(context.restrictions));
		assertEquals('p1', declarationExtensions.getConcreteName(Iterables.get(context.restrictions, 0)));
	}

	@Test
	def void checkPropertyInitializerValue() {
		val context = newBuilder('''
		uri "http://myUri".
		Foo is a class described by p1 with values of type Foo.
		myFoo is a ''').ontologyContext;

		assertNotNull(context);
		assertEquals(MISSING_SUBJECT, context.subject);
		assertTrue(context.grammarContextId.present);<commit_msg>GH-181: Fixed failing tests.<commit_after>/************************************************************************
 * Copyright © 2007-2017 - General Electric Company, All Rights Reserved
 * 
 * Project: SADL
 * 
 * Description: The Semantic Application Design Language (SADL) is a
 * language for building semantic models and expressing rules that
 * capture additional domain knowledge. The SADL-IDE (integrated
 * development environment) is a set of Eclipse plug-ins that
 * support the editing and testing of semantic models using the
 * SADL language.
 * 
 * This software is distributed "AS-IS" without ANY WARRANTIES
 * and licensed under the Eclipse Public License - v 1.0
 * which is available at http://www.eclipse.org/org/documents/epl-v10.php
 * 
 ***********************************************************************/
package com.ge.research.sadl.ui.tests.contentassist

import com.ge.research.sadl.model.DeclarationExtensions
import com.google.common.collect.Iterables
import org.junit.Test

import static com.ge.research.sadl.processing.ISadlOntologyHelper.ContextBuilder.*
import static com.ge.research.sadl.processing.ISadlOntologyHelper.GrammarContextIds.*
import static org.junit.Assert.*

/**
 * Test for transforming Eclipse-based content assist contexts into ontology helper contexts.
 * 
 * @author akos.kitta
 */
class SadlOntologyContextTest extends AbstractSadlContentAssistTest {

	@Test
	def void checkPropertyInitializerValueWithRestrictions() {
		val context = newBuilder('''
		uri "http://myUri". 
		Foo is a class described by p1 with values of type Foo. 
		myFoo is a Foo with p1 ''').ontologyContext;

		assertNotNull(context);
		assertNotEquals(MISSING_SUBJECT, context.subject);
		assertTrue(context.grammarContextId.present);
		assertEquals(SADLPROPERTYINITIALIZER_VALUE, context.grammarContextId.get);
		assertEquals(1, Iterables.size(context.restrictions));
		assertEquals('p1', declarationExtensions.getConcreteName(Iterables.get(context.restrictions, 0)));
	}

	@Test
	def void checkPropertyInitializerValue() {
		val context = newBuilder('''
		uri "http://myUri".
		Foo is a class described by p1 with values of type Foo.
		myFoo is a ''').ontologyContext;

		assertNotNull(context);
		assertNotEquals(MISSING_SUBJECT, context.subject);
		assertTrue(context.grammarContextId.present);
{'fraction_non_alphanumeric': 0.14756570443774236, 'fraction_numerical': 0.00840155105557949, 'mean_word_length': 5.3084239130434785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4676157', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1244, 'n_words': 366}