@Test
public void testRepositoryVersionNotSetDuringUpgrade() throws Exception {

  // this call will make it seem like there is an upgrade in progress
  expect(cluster.getUpgradeInProgress()).andReturn(createNiceMock(UpgradeEntity.class));
  // create the DAO - nothing will be called on it, so make it strict
  RepositoryVersionDAO dao = createStrictMock(RepositoryVersionDAO.class);
  replayAll();
  // !!! avoid injector for test class
  Field field = StackVersionListener.class.getDeclaredField("repositoryVersionDAO");
  field.setAccessible(true);
  field.set(listener, dao);
  HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cluster,
      sch, VALID_NEW_VERSION, 1L);
  // make sure that a repo ID will come back
  Assert.assertNotNull(event.getRepositoryVersionId());
  listener.onAmbariEvent(event);
  verifyAll();
}