Beispiel #1
0
 /* (non-Javadoc)
  * @see com.cyc.kb.KBTerm#provablyNotInstanceOf(com.cyc.kb.KBCollectionImpl, com.cyc.kb.ContextImpl)
  */
 @Override
 public boolean provablyNotInstanceOf(KBCollection col, Context ctx) {
   try {
     return getAccess()
         .getInspectorTool()
         .isa(this.getCore(), KBObjectImpl.getCore(col), KBObjectImpl.getCore(ctx));
   } catch (CycConnectionException e) {
     throw new KBApiRuntimeException(e.getMessage(), e);
   }
 }
Beispiel #2
0
  @Test
  public void testFactFactories()
      throws KBTypeException, CreateException, ParseException, DeleteException {

    // Only GAFs can be Fact.class
    System.out.println("Running testFactFactories");
    System.out.println("Testing that only GAFs can be Facts");
    try {
      @SuppressWarnings("deprecation")
      Fact f = FactImpl.get(KBObjectImpl.getCore(TestConstants.flyingRule));
    } catch (KBObjectNotFoundException kboe) {
      // @todo isn't this an error/failure???
      System.out.println("Got Exception: " + kboe.toString());
    }

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd HH:mm");
    Context airlineLogMt = ContextImpl.findOrCreate("SomeAirlineLogMt");
    KBIndividual flight = KBIndividualImpl.get("FlightXYZ-APITest");

    Date d = sdf.parse("2014 03 15 10:20");
    SentenceImpl s = new SentenceImpl(TestConstants.kbapitc.endingDate, flight, d);
    Assertion a = AssertionImpl.get(s, airlineLogMt);
    @SuppressWarnings("deprecation")
    Fact flDate = FactImpl.get(KBObjectImpl.getCore(a));

    System.out.println("Testing HLID Factory");
    String hlid = a.getId();
    Fact flDate1 = FactImpl.get(hlid);
    assertTrue("Fact not equal to one from HLID", flDate1 == flDate);

    // Get based on formula and context strings
    System.out.println("Testing factory get(formulaStr, ctxStr)");
    Fact flDate2 = FactImpl.get(s.toString(), airlineLogMt.toString());
    assertTrue("Fact not equal to one from formulaStr, ctxStr", flDate2 == flDate);

    System.out.println("Testing factory get(formula, ctx)");
    Fact flDate3 = FactImpl.get(s, airlineLogMt);
    assertTrue("Fact not equal to one from formula, ctx", flDate3 == flDate);

    FirstOrderCollectionImpl flying2Col = FirstOrderCollectionImpl.get("Flying-Move");
    KBIndividual flight2 =
        KBIndividualImpl.findOrCreate("FlightABC-APITest", flying2Col, airlineLogMt);

    SentenceImpl s2 = new SentenceImpl(TestConstants.kbapitc.endingDate, flight2, d);
    FactImpl fl2Date = FactImpl.findOrCreate(s2, airlineLogMt);
    fl2Date.delete();

    Fact fl3Date = FactImpl.findOrCreate(s2.toString(), airlineLogMt.toString());
    assertFalse("Probably failed to assert, HLID is empty string", fl2Date.getId().equals(""));
  }