/** @throws java.lang.Exception */
 @Before
 public void setUp() throws Exception {
   final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
   when(store.getChildren()).thenReturn(Collections.singletonList(fileStore));
   final BusinessObjectData data =
       aBusinessData()
           .havingDataType(BusinessObjectDataTypeBuilder.aBusinessObjectDataType())
           .build();
   final Pool pool = aPool().build();
   pool.getData().add(data);
   wizardPageUnderTest =
       new BusinessObjectDataWizardPage(pool, data, store, newHashSet("data1"), hintImageProvider);
   doReturn(realmWithDisplay.createImage()).when(hintImageProvider).getHintImage();
   wizardPageUnderTest.setWizard(wizardWithContainer);
   when(wizardWithContainer.getContainer()).thenReturn(wizardContainer);
   when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
 }
  @Test
  public void
      should_create_operation_for_given_multiple_business_data_and_generated_contract_input()
          throws Exception {
    final SimpleField firstNameField = SimpleFieldBuilder.aStringField("firstName").build();
    final SimpleFieldToContractInputMapping mapping =
        new SimpleFieldToContractInputMapping(firstNameField);

    final BusinessObjectModelRepositoryStore businessObjectStore =
        mock(BusinessObjectModelRepositoryStore.class);
    final BusinessObject bo = aBO("org.test.Employee").withField(firstNameField).build();
    when(businessObjectStore.getBusinessObjectByQualifiedName("org.test.Employee")).thenReturn(bo);
    final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
    when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class))
        .thenReturn(businessObjectStore);
    final FieldToContractInputMappingOperationBuilder operationBuilder =
        mock(FieldToContractInputMappingOperationBuilder.class);
    final RootContractInputGenerator rootContractInputGenerator =
        new RootContractInputGenerator(
            "employeesInput",
            newArrayList(mapping),
            repositoryAccessor,
            operationBuilder,
            mock(FieldToContractInputMappingExpressionBuilder.class));
    final BusinessObjectData businessObjectData =
        aBusinessData().withName("employees").withClassname("org.test.Employee").multiple().build();
    rootContractInputGenerator.build(businessObjectData);

    final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor =
        ArgumentCaptor.forClass(FieldToContractInputMapping.class);
    verify(operationBuilder).toOperation(eq(businessObjectData), argumentCaptor.capture());
    final Field field = argumentCaptor.getValue().getField();
    assertThat(field).isInstanceOf(RelationField.class);
    assertThat(field.getName()).isEqualTo("employeesInput");
    assertThat(field.isCollection()).isTrue();
    assertThat(((RelationField) field).getReference().getQualifiedName())
        .isEqualTo("org.test.Employee");
    assertThat(((RelationField) field).getType()).isEqualTo(RelationField.Type.COMPOSITION);
  }