/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.commons.rdf.jena;

import static org.junit.Assert.*;

import org.apache.commons.rdf.api.BlankNode;
import org.junit.Test;

public class GeneralizedRDFTripleTest {

    private JenaRDF jena = new JenaRDF();
    
    @Test
    public void bnodeProperty() throws Exception {
        BlankNode b1 = jena.createBlankNode("b1");
        JenaIRI ex1 = jena.createIRI("http://example.com/ex1");
        JenaIRI ex2 = jena.createIRI("http://example.com/ex2");
        
        JenaGeneralizedTripleLike t = jena.createGeneralizedTriple(ex1, b1, ex2);
        assertEquals(ex1, t.getSubject());
        assertEquals(ex2, t.getObject());
        assertEquals(b1, t.getPredicate()); // it's a bnode!
        assertTrue(t.asJenaTriple().getPredicate().isBlank());
    }

    @Test
    public void literalPredicate() throws Exception {
        JenaIRI ex1 = jena.createIRI("http://example.com/ex1");
        JenaIRI ex2 = jena.createIRI("http://example.com/ex2");
        JenaLiteral lit = jena.createLiteral("Hello");
        
        JenaGeneralizedTripleLike t = jena.createGeneralizedTriple(ex1, lit, ex2);
        assertEquals(ex1, t.getSubject());
        assertEquals(ex2, t.getObject());
        assertEquals(lit, t.getPredicate()); // it's a literal!
        assertTrue(t.asJenaTriple().getPredicate().isLiteral());
    }


    @Test
    public void literalSubject() throws Exception {
        JenaIRI ex1 = jena.createIRI("http://example.com/ex1");
        JenaIRI ex2 = jena.createIRI("http://example.com/ex2");
        JenaLiteral lit = jena.createLiteral("Hello");
        
        JenaGeneralizedTripleLike t = jena.createGeneralizedTriple(lit, ex1, ex2);
        assertEquals(lit, t.getSubject()); // it's a literal!
        assertEquals(ex1, t.getPredicate());
        assertEquals(ex2, t.getObject());
        assertTrue(t.asJenaTriple().getSubject().isLiteral());
    }
    
    

    
}

@@ -873,54 +873,222 @@
 ert.
-*;%0A%0Aimport org.apache.commons.rdf.api.BlankNod
+assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport org.apache.commons.rdf.api.BlankNode;%0Aimport org.apache.jena.graph.Node;%0Aimport org.apache.jena.graph.NodeFactory;%0Aimport org.apache.jena.graph.Tripl
 e;%0Ai
@@ -2870,17 +2870,555 @@
    %0A    
-%0A
+@Test%0A    public void asGeneralizedTriple() throws Exception %7B%0A        Node s = NodeFactory.createLiteral(%22Hello%22);%0A        Node p = NodeFactory.createBlankNode();%0A        Node o = NodeFactory.createURI(%22http://example.com/ex%22);%0A        Triple jt = Triple.create(s, p, o);%0A        JenaTripleLike t = jena.asGeneralizedTriple(jt);%0A        assertEquals(jena.createLiteral(%22Hello%22), t.getSubject());%0A        assertEquals(jena.asRDFTerm(p), t.getPredicate());%0A        assertEquals(jena.createIRI(%22http://example.com/ex%22), t.getObject());%0A    %7D
 %0A    %0A%7D%0A

Test asGeneralizedTriple