@Test
  public void testShouldCreateTargetForValidSBMLDocument() {
    assertFalse(exportAdapter.isTargetCreated());
    final IModelFactory moeckModelFactory = mockery.mock(IModelFactory.class, "mockModelFactory");
    final IModel mockModel = mockery.mock(IModel.class, "mockModel");
    final IEntityFactory mockentityFac = mockery.mock(IEntityFactory.class, "mockentityFac");
    final IReactionBuilder mockReactionFactory =
        mockery.mock(IReactionBuilder.class, "mockReactionFactory");
    final SBMLDocument doc = createSBMLDocument();
    mockery.checking(
        new Expectations() {
          {
            one(moeckModelFactory)
                .createSBMLModel(with(any(SBMLDocument.class)), with(any(IModel.class)));
          }

          {
            will(returnValue(doc.getModel()));
          }

          {
            one(mockentityFac)
                .buildSpeciesAndCompartments(with(any(Model.class)), with(any(IModel.class)));
          }

          {
            will(returnValue(doc.getModel()));
          }

          {
            one(mockReactionFactory)
                .buildReactions(with(any(Model.class)), with(any(IModel.class)));
          }
        });
    addDependencies(moeckModelFactory, mockentityFac, doc, mockReactionFactory);

    exportAdapter = stubexportAdapter;
    // use SUT
    try {
      exportAdapter.createTarget(mockModel);
    } catch (ExportAdapterCreationException e) {
      fail(e.getMessage());
    }
    // validate
    mockery.assertIsSatisfied();
    assertTrue(exportAdapter.isTargetCreated());
  }
  @Test(expected = ExportAdapterCreationException.class)
  public void testCreateTargetThrowsExceptionForInValidSBMLDocument() throws Exception {
    assertFalse(exportAdapter.isTargetCreated());
    final IModelFactory moeckModelFactory = mockery.mock(IModelFactory.class);
    final IModel mockModel = mockery.mock(IModel.class);
    final IEntityFactory mockentityFac = mockery.mock(IEntityFactory.class);
    final IReactionBuilder mockReactionFactory = mockery.mock(IReactionBuilder.class);
    final SBMLDocument doc = createSBMLDocument();
    mockery.checking(
        new Expectations() {
          {
            one(moeckModelFactory)
                .createSBMLModel(with(any(SBMLDocument.class)), with(any(IModel.class)));
          }

          {
            will(returnValue(doc.getModel()));
          }

          {
            one(mockentityFac)
                .buildSpeciesAndCompartments(with(any(Model.class)), with(any(IModel.class)));
          }

          {
            will(returnValue(doc.getModel()));
          }

          {
            one(mockReactionFactory)
                .buildReactions(with(any(Model.class)), with(any(IModel.class)));
          }
        });
    exportAdapter = stubexportAdapter;
    addDependencies(moeckModelFactory, mockentityFac, doc, mockReactionFactory);

    // use SUT
    // invalidates model - reaction with no specuies
    doc.getModel().addReaction(new Reaction());
    exportAdapter.createTarget(mockModel);

    // validate
    mockery.assertIsSatisfied();
    assertFalse(exportAdapter.isTargetCreated());
  }
  @Test(expected = IllegalStateException.class)
  public void testWriteTargetFailsIfTargetNotCreated() throws Exception {

    exportAdapter.writeTarget(new FileOutputStream(aFile));
  }
 @Test(expected = IllegalArgumentException.class)
 public void testWriteTargetPrecondition1() throws Exception {
   exportAdapter.writeTarget(null);
   assertFalse(exportAdapter.isTargetCreated());
 }
 @Test
 public void testIsTargetCreatedIsInitiallyFalse() {
   assertFalse(exportAdapter.isTargetCreated());
 }
 @Test(expected = IllegalArgumentException.class)
 public void testCreateTargetPreconditions() throws Exception {
   exportAdapter.createTarget(null);
 }