@Test public void testConstructAssertion() throws KBApiException { System.out.println("Running testConstructAssertion"); // "(SomeAirlineEquipmentLogFn Plane-APITest)", "(flyingDoneBySomething-Move FlightXYZ-APITest // Plane-APITest)" KBPredicate p = KBPredicateImpl.get("flyingDoneBySomething-Move"); KBIndividual flight = KBIndividualImpl.get("FlightXYZ-APITest"); KBIndividual plane = KBIndividualImpl.get("Plane-APITest"); List<Object> arguments = new ArrayList<Object>(); arguments.add(flight); arguments.add(plane); Context ctx = ContextImpl.get("(SomeAirlineEquipmentLogFn Plane-APITest)"); Fact a = new FactImpl(ctx, p, arguments.toArray()); assertTrue("Unable to get a fact from " + p + " " + arguments, a instanceof Fact); // System.out.println("Fact string: " + a.toString()); // With date ContextImpl airlineLog = ContextImpl.get("SomeAirlineLogMt"); KBPredicate start = TestConstants.kbapitc.startingDate; SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd HH:mm"); try { Date d = sdf.parse("2014 03 15 8:05"); Fact wellA = new FactImpl(airlineLog, start, flight, d); Date checkd = wellA.<Date>getArgument(2); assertEquals(checkd, d); } catch (ParseException pe) { // ignore ???@todo Aren't these failures, if we get here??? } }
@Test public void testAddAndGetSentence() throws KBApiException { System.out.println("Running testAddAndGetSentence"); KBIndividualImpl i = KBIndividualImpl.findOrCreate("SomeRandom-LS"); i.isInstanceOf(KBCollectionImpl.get("LogicalSchema")); KBPredicateImpl p = KBPredicateImpl.get("meaningSentenceOfSchema"); List<Object> l = new ArrayList<Object>(); l.add(KBPredicateImpl.get("isa")); l.add(i); l.add(p); Sentence s = new SentenceImpl(l.toArray()); i.addFact(ContextImpl.get("UniversalVocabularyMt"), p, 1, s); Collection<Fact> lfs = i.getFacts(p, 1, ContextImpl.get("UniversalVocabularyMt")); KBIndividual iback = lfs.iterator().next().<KBIndividual>getArgument(1); Sentence a = lfs.iterator().next().<Sentence>getArgument(2); assertTrue("Didn't get sentence", (a instanceof Sentence)); }
@Test public void testFactContextObject() throws KBApiException { System.out.println("Running testFactContextObject"); Context uctx = Constants.uvMt(); Fact anA = new FactImpl( "(SomeAirlineEquipmentLogFn Plane-APITest)", "(flyingDoneBySomething-Move FlightXYZ-APITest Plane-APITest)"); Fact anAonA = new FactImpl( "(SomeAirlineEquipmentLogFn Plane-APITest)", "(#$assertionUtility (#$ist (SomeAirlineEquipmentLogFn Plane-APITest) (flyingDoneBySomething-Move FlightXYZ-APITest Plane-APITest)) 0.5 )"); KBPredicate p = KBPredicateImpl.get("assertionUtility"); FactImpl a = new FactImpl(uctx, p, anA, 0.89); assertEquals( "(ist UniversalVocabularyMt (assertionUtility (() ((#$flyingDoneBySomething-Move #$FlightXYZ-APITest #$Plane-APITest))) 0.89))", a.toString()); assertEquals(a.getContext().toString(), "UniversalVocabularyMt"); }