/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class defines a set of tests for the
* {@link org.opends.server.types.AttributeType} class.
*/
/**
* Internal class to simplify construction of attribute types.
*/
private static final class AttributeTypeBuilder extends
/** The superior attribute type from which this attribute type inherits. */
/** The syntax for this attribute type. */
/** The approximate matching rule for this attribute type. */
/** The equality matching rule for this attribute type. */
/** The ordering matching rule for this attribute type. */
/** The substring matching rule for this attribute type. */
/** The attribute usage for this attribute type. */
/** Indicates whether this attribute type is declared "collective". */
private boolean isCollective;
/**
* Indicates whether this attribute type is declared "no-user-modification".
*/
private boolean isNoUserModification;
/**
* Indicates whether this attribute type is declared "single-value".
*/
private boolean isSingleValue;
/** {@inheritDoc} */
protected void resetBuilder() {
this.superiorType = null;
this.approximateMatchingRule = null;
this.equalityMatchingRule = null;
this.orderingMatchingRule = null;
this.substringMatchingRule = null;
this.isCollective = false;
this.isNoUserModification = false;
this.isSingleValue = false;
}
/**
* Create a new attribute type builder.
*/
public AttributeTypeBuilder() {
super();
}
/**
* Create a new attribute type builder.
*
* @param primaryName
* The attribute type primary name.
* @param oid
* The attribute type OID.
*/
super(primaryName, oid);
}
/** {@inheritDoc} */
if (primaryName != null)
{
}
{
}
{
{
}
else
{
}
}
if (description != null)
{
}
if (isObsolete)
{
}
if (superiorType != null)
{
}
if (equalityMatchingRule != null)
{
}
if (orderingMatchingRule != null)
{
}
if (substringMatchingRule != null)
{
}
{
}
if (isSingleValue)
{
}
if (isCollective)
{
}
if (isNoUserModification)
{
}
if (attributeUsage != null)
{
}
if (extraProperties != null)
{
{
{
continue;
}
{
}
else
{
{
}
}
}
}
}
/**
* Set the approximateMatchingRule.
*
* @param approximateMatchingRule
* The approximateMatchingRule.
*/
}
/**
* Set the attributeUsage.
*
* @param attributeUsage
* The attributeUsage.
*/
this.attributeUsage = attributeUsage;
}
/**
* Set the equalityMatchingRule.
*
* @param equalityMatchingRule
* The equalityMatchingRule.
*/
public void setEqualityMatchingRule(
}
/**
* Set the isCollective.
*
* @param isCollective
* The isCollective.
*/
this.isCollective = isCollective;
}
/**
* Set the isNoUserModification.
*
* @param isNoUserModification
* The isNoUserModification.
*/
}
/**
* Set the isSingleValue.
*
* @param isSingleValue
* The isSingleValue.
*/
this.isSingleValue = isSingleValue;
}
/**
* Set the orderingMatchingRule.
*
* @param orderingMatchingRule
* The orderingMatchingRule.
*/
public void setOrderingMatchingRule(
}
/**
* Set the substringMatchingRule.
*
* @param substringMatchingRule
* The substringMatchingRule.
*/
public void setSubstringMatchingRule(
}
/**
* Set the superiorType.
*
* @param superiorType
* The superiorType.
*/
this.superiorType = superiorType;
}
/**
* Set the syntax.
*
* @param syntax
* The syntax.
*/
}
}
/**
* Check that the simple constructor throws an NPE when mandatory
* parameters are not specified.
*
* @throws Exception
* If the test failed unexpectedly.
*/
false, false, false, false);
}
/**
* Check that the complex constructor throws an NPE when mandatory
* parameters are not specified.
*
* @throws Exception
* If the test failed unexpectedly.
*/
}
/**
* Check that the complex constructor does not throw an exception
* when all optional parameters are not specified.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
false, false, null);
}
/**
* Check constructor sets the default usage correctly.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
}
/**
* Check constructor sets the default syntax correctly.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
}
/**
* Check constructor sets the syntax correctly.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
}
/**
* Check constructor inherits the syntax from the parent type when
* required.
*
* @throws Exception
* If the test failed unexpectedly.
*/
"parentType", "1.2.3");
}
/**
* Check constructor sets the default matching rules correctly.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
}
/**
* Check constructor sets the matching rules correctly.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
}
/**
* Check constructor inherits the matching rules from the parent
* type when required.
*
* @throws Exception
* If the test failed unexpectedly.
*/
"parentType", "1.2.3");
}
/**
* Create test data for testing the
* {@link AttributeType#isObjectClass()} method.
*
* @return Returns the array of test data.
*/
return new Object[][] { { "testType", false },
{ "objectclass", true }, { "objectClass", true },
{ "OBJECTCLASS", true } };
}
/**
* Check that the objectClass attribute type is correctly
* identified.
*
* @param name
* The primary name.
* @param result
* The expected result.
* @throws Exception
* If the test failed unexpectedly.
*/
throws Exception {
"1.2.3");
}
/**
* Check that the {@link AttributeType#isCollective()} method.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
builder.setCollective(true);
}
/**
* Check that the {@link AttributeType#isNoUserModification()}
* method.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
builder.setNoUserModification(true);
}
/**
* Check that the {@link AttributeType#isSingleValue()} method.
*
* @throws Exception
* If the test failed unexpectedly.
*/
@Test
"testType", "1.2.3");
builder.setSingleValue(true);
}
/**
* Create test data for testing the
* {@link AttributeType#isOperational()} method.
*
* @return Returns the array of test data.
*/
{ AttributeUsage.USER_APPLICATIONS, false },
{ AttributeUsage.DIRECTORY_OPERATION, true },
{ AttributeUsage.DISTRIBUTED_OPERATION, true },
{ AttributeUsage.DSA_OPERATION, true } };
}
/**
* Check that the {@link AttributeType#isOperational()} method.
*
* @param usage
* The attribute usage.
* @param result
* Expected result.
* @throws Exception
* If the test failed unexpectedly.
*/
throws Exception {
"testType", "1.2.3");
}
/** {@inheritDoc} */
}
}