/** Tests the method <code>EcoreDataType.getNamespace()</code>. */
  @Test
  public void testGetNamespace1() {

    String msg;

    msg = "The adaptation of EDataType.getNamespace() seems to be wrong.";

    /* The type should belong to the right name space. */
    assertEquals(msg, package1, nonPrimitiveDataType.getNamespace());
  }
  /** Tests the method <code>EcoreDataType.getName()</code>. */
  @Test
  public void testGetName1() {

    String msg;

    msg = "The adaptation of EDataType.getName() seems to be wrong.";

    /* The type should have the right name. */
    assertEquals(msg, PRIMITIVETYPE_NAME_NONPRIMITIVEDATATYPE, nonPrimitiveDataType.getName());
  }
  /*
   * (non-Javadoc)
   * @see tudresden.ocl20.pivot.modelinstancetype.types.IModelInstanceElement
   * #asType(tudresden.ocl20.pivot.pivotmodel.Type)
   */
  public IModelInstanceElement asType(Type type) throws AsTypeCastException {

    if (type == null) {
      throw new IllegalArgumentException("Parameter 'type' must not be null.");
    }
    // no else.

    IModelInstanceElement result;

    /* By default the result is null. */
    result = null;

    /* Booleans can only be casted to primitive types. */
    if (type instanceof PrimitiveType) {

      PrimitiveType primitiveType;
      primitiveType = (PrimitiveType) type;

      /* Check the given PrimitiveTypeKind. */
      if (primitiveType.getKind().equals(PrimitiveTypeKind.BOOLEAN)) {

        /* Create a new boolean to avoid side effects. */
        result = new JavaModelInstanceBoolean(this.myBoolean);
      } else if (primitiveType.getKind().equals(PrimitiveTypeKind.STRING)) {

        if (this.myBoolean == null) {
          result = new JavaModelInstanceString(null);
        } else {
          result = new JavaModelInstanceString(this.myBoolean.toString());
        }
      }
      // no else.
    }
    // no else.

    /* Probably throw an AsTypeCastException. */
    if (result == null) {
      String msg;

      msg = ModelInstanceMessages.IModelInstanceElement_CannotCast;
      msg = NLS.bind(msg, this.getName(), type.getName());

      throw new AsTypeCastException(msg);
    }
    // no else.

    return result;
  }