@Test public void testHybridMobileManagerUpdateEngines() throws CoreException { final HybridMobileEngine[] engines = new HybridMobileEngine[2]; engines[0] = new HybridMobileEngine(); engines[0].setId("platform_0"); engines[0].setVersion("0.0.0"); engines[1] = new HybridMobileEngine(); engines[1].setId("platform_1"); engines[1].setVersion("1.1.1"); manager.updateEngines(engines); Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead(); assertEquals(engines.length, w.getEngines().size()); checkEnginesPersistedCorrectly(engines); manager.updateEngines(engines); w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead(); assertEquals(engines.length, w.getEngines().size()); checkEnginesPersistedCorrectly(engines); }
// Check given set of engines are persisted to config.xml correctly private void checkEnginesPersistedCorrectly(final HybridMobileEngine[] engines) throws CoreException { Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead(); assertEquals(engines.length, w.getEngines().size()); List<Engine> persistedEngines = w.getEngines(); for (HybridMobileEngine hybridMobileEngine : engines) { boolean enginePersisted = false; for (Engine engine : persistedEngines) { if (hybridMobileEngine.getId().equals(engine.getName()) && hybridMobileEngine.getVersion().equals(engine.getVersion())) { enginePersisted = true; break; } } assertTrue("HybridMobile Engine is not persisted correctly", enginePersisted); } }
@Before public void setUpHybridMobileManager() throws CoreException { testproject = new TestProject(); manager = new HybridMobileEngineManager(testproject.hybridProject()); }