### Question:
FireflyExtension { public boolean isUpdateRequired() { try { FireflyExtensionModel fireflyExtensionModel = fireflyExtensionRepository.findByName(name); return !containsItemDefinitionHash(getItemsDefinitionHash(), relaxedMode ? fireflyExtensionModel.getStates() : asList(getLastState(fireflyExtensionModel))); } catch (FireflyExtensionRepository.FireflyExtensionNotFoundException e) { return true; } } FireflyExtension(String name, File rootPath, FireflyExtensionRepository fireflyExtensionRepository, MigrationRepository migrationRepository, boolean relaxedMode); boolean isUpdateRequired(); boolean isHmcResetRequired(); void onHmcReset(PK migration); void onUpdate(PK migration); @Override String toString();  }### Answer:
@Test public void shouldNotRequireUpdateIfDefinitionHashHasNotChanged() throws Exception { FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState(generateMD5(ITEMS_XML_CONTENT), null)); given(fireflyExtensionRepository.findByName(EXTENSION_WITH_ITEMS_XML)).willReturn(fireflyExtensionModel); boolean updateRequired = fireflyExtension.isUpdateRequired(); assertFalse(updateRequired); }
@Test public void shouldNotRequireUpdateIfExtensionHasNoItemsXml() throws Exception { fireflyExtension = createExtension(EXTENSION_WITHOUT_ITEMS_XML, false); FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState(NO_ITEMS_XML_MD5, null)); given(fireflyExtensionRepository.findByName(EXTENSION_WITHOUT_ITEMS_XML)).willReturn(fireflyExtensionModel); boolean updateRequired = fireflyExtension.isUpdateRequired(); assertFalse(updateRequired); }
@Test public void shouldRequireUpdateForNewExtension() throws Exception { givenExtensionIsNotInRepository(EXTENSION_WITH_ITEMS_XML); boolean updateRequired = fireflyExtension.isUpdateRequired(); assertTrue(updateRequired); }
@Test public void shouldRequireUpdateIfDefinitionHashIsChanged() throws Exception { FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState("SOME_VALUE", null)); given(fireflyExtensionRepository.findByName(EXTENSION_WITH_ITEMS_XML)).willReturn(fireflyExtensionModel); boolean updateRequired = fireflyExtension.isUpdateRequired(); assertTrue(updateRequired); }
@Test public void shouldNotRequireUpdateIfDefinitionHashIsInHistory() throws Exception { fireflyExtension = createExtension(EXTENSION_WITH_ITEMS_XML, true); FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState(generateMD5(ITEMS_XML_CONTENT), null), mockState("SOME_VALUE", null)); given(fireflyExtensionRepository.findByName(EXTENSION_WITH_ITEMS_XML)).willReturn(fireflyExtensionModel); boolean updateRequired = fireflyExtension.isUpdateRequired(); assertFalse(updateRequired); }