// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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 org.hibernate.jsr303.tck.tests.metadata;
import javax.validation.metadata.PropertyDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.getPropertyDescriptor;
/**
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class PropertyDescriptorTest extends AbstractTest {
@Test
@SpecAssertion(section = "5.4", id = "a")
public void testIsNotCascaded() {
PropertyDescriptor descriptor = getPropertyDescriptor( Order.class, "orderNumber" );
assertFalse( descriptor.isCascaded(), "Should not be cascaded" );
}
@Test
@SpecAssertion(section = "5.4", id = "a")
public void testIsCascaded() {
PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, "orderList" );
assertTrue( descriptor.isCascaded(), "Should be cascaded" );
}
@Test
@SpecAssertion(section = "5.4", id = "b")
public void testPropertyName() {
String propertyName = "orderList";
PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, propertyName );
assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" );
}
}