@Test
 public void notPersistedWhenDerived() throws Exception {
   // TODO: ISIS-5, need to reinstate DerivedFacet
   final NotPersistedFacet mockFacet = mockFacetIgnoring(NotPersistedFacet.class);
   facetedMethod.addFacet(mockFacet);
   assertTrue(objectAssociation.isNotPersisted());
 }
 private List<ObjectAction> asObjectActions(final OrderSet orderSet) {
   if (orderSet == null) {
     return null;
   }
   final List<ObjectAction> actions = Lists.newArrayList();
   for (final Object element : orderSet) {
     if (element instanceof FacetedMethod) {
       final FacetedMethod facetedMethod = (FacetedMethod) element;
       if (facetedMethod.getFeatureType().isAction()) {
         actions.add(createAction(facetedMethod));
       }
     } else if (element instanceof OrderSet) {
       final OrderSet set = ((OrderSet) element);
       actions.add(createObjectActionSet(set));
     } else {
       throw new UnknownTypeException(element);
     }
   }
   return actions;
 }
  private List<ObjectAssociation> asAssociations(final OrderSet orderSet) {
    if (orderSet == null) {
      return null;
    }
    final List<ObjectAssociation> associations = Lists.newArrayList();
    for (final Object element : orderSet) {
      if (element instanceof FacetedMethod) {
        final FacetedMethod facetMethod = (FacetedMethod) element;
        if (facetMethod.getFeatureType().isCollection()) {
          associations.add(createCollection(facetMethod));
        } else if (facetMethod.getFeatureType().isProperty()) {
          associations.add(createProperty(facetMethod));
        }
      } else if (element instanceof OrderSet) {
        // Not supported at present
      } else {
        throw new UnknownTypeException(element);
      }
    }

    return associations;
  }
  protected ObjectMemberAbstract(
      final FacetedMethod facetedMethod,
      final FeatureType featureType,
      final ObjectMemberContext objectMemberContext) {
    final String id = facetedMethod.getIdentifier().getMemberName();
    if (id == null) {
      throw new IllegalArgumentException("Name must always be set");
    }
    this.facetedMethod = facetedMethod;
    this.featureType = featureType;
    this.id = id;
    this.defaultName = NameUtils.naturalName(this.id);

    this.deploymentCategory = objectMemberContext.getDeploymentCategory();
    this.authenticationSessionProvider = objectMemberContext.getAuthenticationSessionProvider();
    this.specificationLookup = objectMemberContext.getSpecificationLookup();
    this.adapterManager = objectMemberContext.getAdapterManager();
    this.querySubmitter = objectMemberContext.getQuerySubmitter();
    this.collectionTypeRegistry = objectMemberContext.getCollectionTypeRegistry();
  }
  @Before
  public void setup() {
    facetedMethod = FacetedMethod.createForProperty(Customer.class, "firstName");

    objectAssociation =
        new ObjectAssociationAbstract(
            facetedMethod,
            FeatureType.PROPERTY,
            objectSpecification,
            new ObjectMemberContext(DeploymentCategory.PRODUCTION, null, null, null, null, null)) {

          @Override
          public ObjectAdapter get(final ObjectAdapter fromObject) {
            return null;
          }

          @Override
          public boolean isEmpty(final ObjectAdapter adapter) {
            return false;
          }

          @Override
          public ObjectAdapter[] getChoices(final ObjectAdapter object) {
            return null;
          }

          @Override
          public ObjectAdapter getDefault(final ObjectAdapter adapter) {
            return null;
          }

          @Override
          public void toDefault(final ObjectAdapter target) {}

          @Override
          public UsabilityContext<?> createUsableInteractionContext(
              final AuthenticationSession session,
              final InteractionInvocationMethod invocationMethod,
              final ObjectAdapter target,
              Where where) {
            return null;
          }

          @Override
          public VisibilityContext<?> createVisibleInteractionContext(
              final AuthenticationSession session,
              final InteractionInvocationMethod invocationMethod,
              final ObjectAdapter targetObjectAdapter,
              Where where) {
            return null;
          }

          @Override
          public String debugData() {
            return null;
          }

          @Override
          public Instance getInstance(final ObjectAdapter adapter) {
            return null;
          }

          @Override
          public boolean containsDoOpFacet(final Class<? extends Facet> facetType) {
            return false;
          }

          @Override
          public boolean hasAutoComplete() {
            return false;
          }

          @Override
          public ObjectAdapter[] getAutoComplete(ObjectAdapter object, String searchArg) {
            return null;
          }

          @Override
          public int getAutoCompleteMinLength() {
            return 0;
          }
        };
  }
 @Test
 public void hasChoices() throws Exception {
   final PropertyChoicesFacet mockFacet = mockFacetIgnoring(PropertyChoicesFacet.class);
   facetedMethod.addFacet(mockFacet);
   assertTrue(objectAssociation.hasChoices());
 }
 @Test
 public void mandatory() throws Exception {
   final MandatoryFacet mockFacet = mockFacetIgnoring(MandatoryFacet.class);
   facetedMethod.addFacet(mockFacet);
   assertTrue(objectAssociation.isMandatory());
 }
 @Test
 public void notPersistedWhenFlaggedAsNotPersisted() throws Exception {
   final NotPersistedFacet mockFacet = mockFacetIgnoring(NotPersistedFacet.class);
   facetedMethod.addFacet(mockFacet);
   assertTrue(objectAssociation.isNotPersisted());
 }