@Test public void storeSetupExsiting_shouldOverrideOldSetup() throws PersistenceException { store.storeConnectorSetup("test", "42", new HashMap<String, String>()); ConnectorSetupBean setupBean = new ConnectorSetupBean("test", "42", new HashMap<String, String>()); Mockito.verify(persistence).delete(Mockito.refEq(setupBean, "properties")); Mockito.verify(persistence).create(Mockito.refEq(setupBean, "properties")); }
@Test public void deleteSetup_shouldWork() throws PersistenceException { store.deleteConnectorSetup("test", "42"); ConnectorSetupBean setupBean = new ConnectorSetupBean("test", "42", new HashMap<String, String>()); Mockito.verify(persistence).delete(Mockito.refEq(setupBean, "properties")); }
@Before public void setUp() throws PersistenceException { store = new PersistenceConnectorSetupStore(); persistence = Mockito.mock(PersistenceService.class); PersistenceManager managerMock = Mockito.mock(PersistenceManager.class); Mockito.when(managerMock.getPersistenceForBundle(Mockito.any(Bundle.class))) .thenReturn(persistence); store.setPersistenceManager(managerMock); store.setBundleContext(Mockito.mock(BundleContext.class)); store.init(); List<ConnectorSetupBean> result = new ArrayList<ConnectorSetupBean>(); HashMap<String, String> map = new HashMap<String, String>(); map.put("foo", "bar"); ConnectorSetupBean setupBean = new ConnectorSetupBean("test", "42", map); ConnectorSetupBean setupBean2 = new ConnectorSetupBean("test", null, map); result.add(setupBean); Mockito.when(persistence.query(Mockito.refEq(setupBean, "properties"))).thenReturn(result); Mockito.when(persistence.query(Mockito.refEq(setupBean2, "properties"))).thenReturn(result); }