changeset 616:838eb2700f6a

Implement Storage.removePojo() Reviewed-by: omajid Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003212.html
author Roman Kennke <rkennke@redhat.com>
date Mon, 17 Sep 2012 23:04:11 +0200
parents 891cb7a0de3a
children a325470a7366
files common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAOImpl.java common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoConverter.java common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAOImpl.java common/core/src/main/java/com/redhat/thermostat/common/storage/MongoRemove.java common/core/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java common/core/src/main/java/com/redhat/thermostat/common/storage/Remove.java common/core/src/main/java/com/redhat/thermostat/common/storage/Storage.java common/core/src/test/java/com/redhat/thermostat/common/dao/AgentInfoDAOTest.java common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoConverterTest.java common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoDAOTest.java common/core/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java common/core/src/test/java/com/redhat/thermostat/common/storage/QueryTestHelper.java common/core/src/test/java/com/redhat/thermostat/common/storage/UpdateTestHelper.java
diffstat 13 files changed, 213 insertions(+), 267 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAOImpl.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/main/java/com/redhat/thermostat/common/dao/AgentInfoDAOImpl.java	Mon Sep 17 23:04:11 2012 +0200
@@ -40,11 +40,11 @@
 import java.util.List;
 
 import com.redhat.thermostat.common.model.AgentInformation;
-import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Cursor;
 import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.storage.Query;
 import com.redhat.thermostat.common.storage.Query.Criteria;
+import com.redhat.thermostat.common.storage.Remove;
 import com.redhat.thermostat.common.storage.Storage;
 import com.redhat.thermostat.common.storage.Update;
 
@@ -108,9 +108,8 @@
 
     @Override
     public void removeAgentInformation(AgentInformation agentInfo) {
-        Chunk chunk = new Chunk(CATEGORY, true);
-        chunk.put(Key.AGENT_ID, agentInfo.getAgentId());
-        storage.removeChunk(chunk);
+        Remove remove = storage.createRemove().from(CATEGORY).where(Key.AGENT_ID, agentInfo.getAgentId());
+        storage.removePojo(remove);
     }
 
     @Override
--- a/common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoConverter.java	Mon Sep 17 23:02:53 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.dao;
-
-import java.util.List;
-
-import com.redhat.thermostat.common.model.BackendInformation;
-import com.redhat.thermostat.common.storage.Chunk;
-
-public class BackendInfoConverter {
-
-    public Chunk toChunk(BackendInformation backendInfo) {
-        Chunk chunk = new Chunk(BackendInfoDAO.CATEGORY, false);
-
-        chunk.put(BackendInfoDAO.BACKEND_NAME, backendInfo.getName());
-        chunk.put(BackendInfoDAO.BACKEND_DESCRIPTION, backendInfo.getDescription());
-        chunk.put(BackendInfoDAO.IS_ACTIVE, backendInfo.isActive());
-        List<Integer> pids = backendInfo.getPids();
-        chunk.put(BackendInfoDAO.PIDS_TO_MONITOR, pids);
-        chunk.put(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES, backendInfo.isObserveNewJvm());
-
-        return chunk;
-    }
-
-    public BackendInformation fromChunk(Chunk parseFrom) {
-        if (!parseFrom.getCategory().equals(BackendInfoDAO.CATEGORY)) {
-            throw new IllegalArgumentException("chunk not a " + BackendInfoDAO.CATEGORY);
-        }
-
-        BackendInformation info = new BackendInformation();
-
-        info.setName(parseFrom.get(BackendInfoDAO.BACKEND_NAME));
-        info.setDescription(parseFrom.get(BackendInfoDAO.BACKEND_DESCRIPTION));
-        info.setActive(parseFrom.get(BackendInfoDAO.IS_ACTIVE));
-        info.setPids(parseFrom.get(BackendInfoDAO.PIDS_TO_MONITOR));
-        info.setObserveNewJvm(parseFrom.get(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES));
-
-        return info;
-    }
-}
--- a/common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAOImpl.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/main/java/com/redhat/thermostat/common/dao/BackendInfoDAOImpl.java	Mon Sep 17 23:04:11 2012 +0200
@@ -40,16 +40,15 @@
 import java.util.List;
 
 import com.redhat.thermostat.common.model.BackendInformation;
-import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Cursor;
 import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.storage.Query;
+import com.redhat.thermostat.common.storage.Query.Criteria;
+import com.redhat.thermostat.common.storage.Remove;
 import com.redhat.thermostat.common.storage.Storage;
-import com.redhat.thermostat.common.storage.Query.Criteria;
 
 public class BackendInfoDAOImpl implements BackendInfoDAO {
 
-    private final BackendInfoConverter converter = new BackendInfoConverter();
     private final Storage storage;
 
     public BackendInfoDAOImpl(Storage storage) {
@@ -79,8 +78,8 @@
 
     @Override
     public void removeBackendInformation(BackendInformation info) {
-        Chunk toRemove = converter.toChunk(info);
-        storage.removeChunk(toRemove);
+        Remove remove = storage.createRemove().from(CATEGORY).where(BACKEND_NAME, info.getName());
+        storage.removePojo(remove);
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/storage/MongoRemove.java	Mon Sep 17 23:04:11 2012 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+
+package com.redhat.thermostat.common.storage;
+
+class MongoRemove implements Remove {
+
+    private Chunk query;
+
+    @Override
+    public Remove from(Category category) {
+        if (query != null) {
+            throw new IllegalStateException();
+        }
+        query = new Chunk(category, false);
+        return this;
+    }
+
+    @Override
+    public <T> Remove where(Key<T> key, T value) {
+        if (query == null) {
+            throw new IllegalStateException();
+        }
+        query.put(key, value);
+        return this;
+    }
+
+    Chunk getChunk() {
+        return query;
+    }
+
+}
--- a/common/core/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java	Mon Sep 17 23:04:11 2012 +0200
@@ -272,7 +272,10 @@
     }
 
     @Override
-    public void removeChunk(Chunk query) {
+    public void removePojo(Remove remove) {
+        assert (remove instanceof MongoRemove);
+        MongoRemove mongoRemove = (MongoRemove) remove;
+        Chunk query = mongoRemove.getChunk();
         Category category = query.getCategory();
         DBCollection coll = getCachedCollection(category.getName());
 
@@ -336,6 +339,11 @@
     }
 
     @Override
+    public Remove createRemove() {
+        return new MongoRemove();
+    }
+
+    @Override
     public <T extends Pojo> Cursor<T> findAllPojos(Query query, Class<T> resultClass) {
         MongoQuery mongoQuery =  checkAndCastQuery(query);
         DBCollection coll = getCachedCollection(mongoQuery.getCollectionName());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/storage/Remove.java	Mon Sep 17 23:04:11 2012 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+
+package com.redhat.thermostat.common.storage;
+
+
+public interface Remove {
+
+    Remove from(Category category);
+
+    <T> Remove where(Key<T> key, T value);
+
+}
--- a/common/core/src/main/java/com/redhat/thermostat/common/storage/Storage.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/main/java/com/redhat/thermostat/common/storage/Storage.java	Mon Sep 17 23:04:11 2012 +0200
@@ -63,7 +63,7 @@
 
     public abstract void updatePojo(Update update);
 
-    public abstract void removeChunk(Chunk chunk);
+    public abstract void removePojo(Remove remove);
 
     /**
      * Drop all data related to the currently running agent.
@@ -84,4 +84,5 @@
 
     public abstract Query createQuery();
     public abstract Update createUpdate();
+    public abstract Remove createRemove();
 }
--- a/common/core/src/test/java/com/redhat/thermostat/common/dao/AgentInfoDAOTest.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/test/java/com/redhat/thermostat/common/dao/AgentInfoDAOTest.java	Mon Sep 17 23:04:11 2012 +0200
@@ -39,7 +39,6 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -57,10 +56,11 @@
 import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Cursor;
 import com.redhat.thermostat.common.storage.Key;
-import com.redhat.thermostat.common.storage.UpdateTestHelper;
 import com.redhat.thermostat.common.storage.Query.Criteria;
+import com.redhat.thermostat.common.storage.Remove;
 import com.redhat.thermostat.common.storage.Storage;
 import com.redhat.thermostat.common.storage.Update;
+import com.redhat.thermostat.common.storage.QueryTestHelper;
 import com.redhat.thermostat.test.MockQuery;
 
 public class AgentInfoDAOTest {
@@ -206,7 +206,7 @@
     @Test
     public void verifyUpdateAgentInformation() {
 
-        Update mockUpdate = UpdateTestHelper.createMockUpdate();
+        Update mockUpdate = QueryTestHelper.createMockUpdate();
         Storage storage = mock(Storage.class);
         when(storage.createUpdate()).thenReturn(mockUpdate);
         AgentInfoDAO dao = new AgentInfoDAOImpl(storage);
@@ -226,19 +226,16 @@
 
     @Test
     public void verifyRemoveAgentInformation() {
+        Remove mockRemove = QueryTestHelper.createMockRemove();
         Storage storage = mock(Storage.class);
+        when(storage.createRemove()).thenReturn(mockRemove);
         AgentInfoDAO dao = new AgentInfoDAOImpl(storage);
 
         dao.removeAgentInformation(agentInfo1);
 
-        ArgumentCaptor<Chunk> queryCaptor = ArgumentCaptor.forClass(Chunk.class);
-        verify(storage).removeChunk(queryCaptor.capture());
-
-        Chunk removeQuery = queryCaptor.getValue();
-        Chunk expectedQuery = new Chunk(AgentInfoDAO.CATEGORY, true);
-        expectedQuery.put(Key.AGENT_ID, agentInfo1.getAgentId());
-
-        assertEquals(expectedQuery, removeQuery);
+        verify(storage).removePojo(mockRemove);
+        verify(mockRemove).from(AgentInfoDAO.CATEGORY);
+        verify(mockRemove).where(Key.AGENT_ID, "1234");
     }
 
 }
--- a/common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoConverterTest.java	Mon Sep 17 23:02:53 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.dao;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.common.model.BackendInformation;
-import com.redhat.thermostat.common.storage.Chunk;
-
-public class BackendInfoConverterTest {
-
-    @Test
-    public void testFromChunk() {
-        final String BACKEND_NAME = "test-backend";
-        final String BACKEND_DESC = "test-backend-description-that-may-be-long";
-        final Boolean ACTIVE = true;
-        final List<Integer> TO_MONITOR = Arrays.asList(new Integer[] { -1, 0, 1 });
-        final Boolean MONITOR_NEW = false;
-
-        Chunk input = new Chunk(BackendInfoDAO.CATEGORY, true);
-        input.put(BackendInfoDAO.BACKEND_NAME, BACKEND_NAME);
-        input.put(BackendInfoDAO.BACKEND_DESCRIPTION, BACKEND_DESC);
-        input.put(BackendInfoDAO.IS_ACTIVE, ACTIVE);
-        input.put(BackendInfoDAO.PIDS_TO_MONITOR, TO_MONITOR);
-        input.put(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES, MONITOR_NEW);
-
-        BackendInfoConverter converter = new BackendInfoConverter();
-
-        BackendInformation result = converter.fromChunk(input);
-
-        assertEquals(BACKEND_NAME, result.getName());
-        assertEquals(BACKEND_DESC, result.getDescription());
-        assertEquals(ACTIVE, result.isActive());
-        assertEquals(MONITOR_NEW, result.isObserveNewJvm());
-        assertEquals(TO_MONITOR, result.getPids());
-    }
-
-    @Test
-    public void testToChunk() {
-        final String BACKEND_NAME = "test-backend";
-        final String BACKEND_DESC = "test-backend-description-that-may-be-long";
-        final Boolean ACTIVE = true;
-        final List<Integer> TO_MONITOR = Arrays.asList(new Integer[] { -1, 0, 1 });
-        final Boolean MONITOR_NEW = false;
-
-        BackendInformation backendInfo = new BackendInformation();
-        backendInfo.setName(BACKEND_NAME);
-        backendInfo.setDescription(BACKEND_DESC);
-        backendInfo.setActive(ACTIVE);
-        backendInfo.setObserveNewJvm(MONITOR_NEW);
-        backendInfo.setPids(TO_MONITOR);
-
-        BackendInfoConverter converter = new BackendInfoConverter();
-
-        Chunk result = converter.toChunk(backendInfo);
-
-        assertEquals(BackendInfoDAO.CATEGORY, result.getCategory());
-
-        assertEquals(BACKEND_NAME, result.get(BackendInfoDAO.BACKEND_NAME));
-        assertEquals(BACKEND_DESC, result.get(BackendInfoDAO.BACKEND_DESCRIPTION));
-        assertEquals(ACTIVE, result.get(BackendInfoDAO.IS_ACTIVE));
-        assertEquals(TO_MONITOR, result.get(BackendInfoDAO.PIDS_TO_MONITOR));
-        assertEquals(MONITOR_NEW, result.get(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES));
-
-    }
-
-}
--- a/common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoDAOTest.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/test/java/com/redhat/thermostat/common/dao/BackendInfoDAOTest.java	Mon Sep 17 23:04:11 2012 +0200
@@ -40,7 +40,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -48,6 +48,7 @@
 
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.InOrder;
 
 import com.redhat.thermostat.common.model.BackendInformation;
 import com.redhat.thermostat.common.storage.Category;
@@ -55,7 +56,9 @@
 import com.redhat.thermostat.common.storage.Cursor;
 import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.storage.Query.Criteria;
+import com.redhat.thermostat.common.storage.Remove;
 import com.redhat.thermostat.common.storage.Storage;
+import com.redhat.thermostat.common.storage.QueryTestHelper;
 import com.redhat.thermostat.test.MockQuery;
 
 public class BackendInfoDAOTest {
@@ -140,19 +143,17 @@
 
     @Test
     public void verifyRemoveBackendInformation() {
+        Remove remove = QueryTestHelper.createMockRemove();
         Storage storage = mock(Storage.class);
-
+        when(storage.createRemove()).thenReturn(remove);
         BackendInfoDAO dao = new BackendInfoDAOImpl(storage);
 
         dao.removeBackendInformation(backendInfo1);
 
-        Chunk backend1 = new Chunk(BackendInfoDAO.CATEGORY, true);
-        backend1.put(BackendInfoDAO.BACKEND_NAME, "backend-name");
-        backend1.put(BackendInfoDAO.BACKEND_DESCRIPTION, "description");
-        backend1.put(BackendInfoDAO.IS_ACTIVE, true);
-        backend1.put(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES, true);
-        backend1.put(BackendInfoDAO.PIDS_TO_MONITOR, Arrays.asList(new Integer[] { -1, 0, 1}));
-        verify(storage).removeChunk(backend1);
+        verify(storage).removePojo(remove);
+        InOrder inOrder = inOrder(remove);
+        inOrder.verify(remove).from(BackendInfoDAO.CATEGORY);
+        inOrder.verify(remove).where(BackendInfoDAO.BACKEND_NAME, "backend-name");
     }
 
 }
--- a/common/core/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java	Mon Sep 17 23:02:53 2012 +0200
+++ b/common/core/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java	Mon Sep 17 23:04:11 2012 +0200
@@ -63,7 +63,7 @@
 import com.redhat.thermostat.common.storage.Query.Criteria;
 import com.redhat.thermostat.common.storage.Storage;
 import com.redhat.thermostat.common.storage.Update;
-import com.redhat.thermostat.common.storage.UpdateTestHelper;
+import com.redhat.thermostat.common.storage.QueryTestHelper;
 import com.redhat.thermostat.test.MockQuery;
 
 public class VmInfoDAOTest {
@@ -283,7 +283,7 @@
 
     @Test
     public void testPutVmStoppedTime() {
-        Update mockUpdate = UpdateTestHelper.createMockUpdate();
+        Update mockUpdate = QueryTestHelper.createMockUpdate();
         Storage storage = mock(Storage.class);
         when(storage.createUpdate()).thenReturn(mockUpdate);
         VmInfoDAO dao = new VmInfoDAOImpl(storage);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/test/java/com/redhat/thermostat/common/storage/QueryTestHelper.java	Mon Sep 17 23:04:11 2012 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+
+package com.redhat.thermostat.common.storage;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class QueryTestHelper {
+
+    @SuppressWarnings("unchecked")
+    public static Update createMockUpdate() {
+        Update mockUpdate = mock(Update.class);
+        when(mockUpdate.from(any(Category.class))).thenReturn(mockUpdate);
+        when(mockUpdate.where(any(Key.class), any())).thenReturn(mockUpdate);
+        when(mockUpdate.set(any(Key.class), any())).thenReturn(mockUpdate);
+        return mockUpdate;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static Remove createMockRemove() {
+        Remove mockRemove = mock(Remove.class);
+        when(mockRemove.from(any(Category.class))).thenReturn(mockRemove);
+        when(mockRemove.where(any(Key.class), any())).thenReturn(mockRemove);
+        return mockRemove;
+    }
+}
--- a/common/core/src/test/java/com/redhat/thermostat/common/storage/UpdateTestHelper.java	Mon Sep 17 23:02:53 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-
-package com.redhat.thermostat.common.storage;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class UpdateTestHelper {
-
-    @SuppressWarnings("unchecked")
-    public static Update createMockUpdate() {
-        Update mockUpdate = mock(Update.class);
-        when(mockUpdate.from(any(Category.class))).thenReturn(mockUpdate);
-        when(mockUpdate.where(any(Key.class), any())).thenReturn(mockUpdate);
-        when(mockUpdate.set(any(Key.class), any())).thenReturn(mockUpdate);
-        return mockUpdate;
-    }
-}