private BapPublisher createAndAddMockPublisher(final String hostConfigurationName) {
   final BapPublisher mockPublisher = mockControl.createMock(BapPublisher.class);
   if (hostConfigurationName != null) {
     mockPublisher.setEffectiveEnvironmentInBuildInfo(
         (AbstractBuild) EasyMock.anyObject(), (BPBuildInfo) EasyMock.anyObject());
     EasyMock.expect(mockPublisher.getConfigName()).andReturn(hostConfigurationName);
   }
   publishers.add(mockPublisher);
   return mockPublisher;
 }
 private BapPublisher createLabeledPublisher(final String label, final boolean expectPerform)
     throws Exception {
   final BapPublisher mockPublisher = mockControl.createMock(BapPublisher.class);
   mockPublisher.setEffectiveEnvironmentInBuildInfo(
       (AbstractBuild) EasyMock.anyObject(), (BPBuildInfo) EasyMock.anyObject());
   expect(mockPublisher.getLabel()).andReturn(new PublisherLabel(label)).anyTimes();
   EasyMock.expect(mockPublisher.getConfigName())
       .andReturn(hostConfiguration.getName())
       .anyTimes();
   if (expectPerform) {
     mockPublisher.perform(hostConfiguration, buildInfo);
   }
   publishers.add(mockPublisher);
   return mockPublisher;
 }
  @Test
  public void testPerformReturnsUnstableWhenNoHostConfigFound() throws Exception {
    final BapPublisher mockPublisher = createAndAddMockPublisher(null);
    mockPublisher.setEffectiveEnvironmentInBuildInfo(
        (AbstractBuild) EasyMock.anyObject(), (BPBuildInfo) EasyMock.anyObject());
    EasyMock.expect(mockPublisher.getConfigName()).andReturn(hostConfiguration.getName());

    Mockito.reset(mockHostConfigurationAccess);
    Mockito.when(mockHostConfigurationAccess.getConfiguration(hostConfiguration.getName()))
        .thenReturn(null);

    final BPInstanceConfig instanceConfig = createInstanceConfig(publishers, false, false, false);
    instanceConfig.setHostConfigurationAccess(mockHostConfigurationAccess);

    assertResult(Result.UNSTABLE, instanceConfig);
    Mockito.verify(mockHostConfigurationAccess).getConfiguration(hostConfiguration.getName());
  }