changeset 2676:b0da6fc3df05

Clean up unnecessary Category/Key code in core DAOs. Reviewed-By: ebaron Review-Thread: http://icedtea.classpath.org/pipermail/thermostat/2017-May/023269.html
author Joshua Matsuoka <jmatsuok@redhat.com>
date Thu, 25 May 2017 14:36:44 -0400
parents 48e7b691d94d
children 36f6b133eb8e
files plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/HostInfoDAO.java plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOCategoryRegistration.java plugins/com.redhat.thermostat.host.overview/common/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.CategoryRegistration plugins/com.redhat.thermostat.host.overview/common/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOCategoryRegistrationTest.java plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOTest.java storage/core/src/main/java/com/redhat/thermostat/storage/dao/AgentInfoDAO.java storage/core/src/main/java/com/redhat/thermostat/storage/dao/BackendInfoDAO.java storage/core/src/main/java/com/redhat/thermostat/storage/dao/NetworkInterfaceInfoDAO.java storage/core/src/main/java/com/redhat/thermostat/storage/dao/VmInfoDAO.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOImpl.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistration.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistration.java storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOImpl.java storage/core/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.CategoryRegistration storage/core/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration storage/core/src/test/java/com/redhat/thermostat/storage/core/CategoryAdapterTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/AdaptedCategoryTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistrationTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOTest.java storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOTest.java
diffstat 23 files changed, 2 insertions(+), 651 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/HostInfoDAO.java	Thu May 25 14:17:22 2017 -0400
+++ b/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/HostInfoDAO.java	Thu May 25 14:36:44 2017 -0400
@@ -38,23 +38,10 @@
 
 import com.redhat.thermostat.annotations.Service;
 import com.redhat.thermostat.host.overview.common.model.HostInfo;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 
 @Service
 public interface HostInfoDAO {
 
-    static Key<String> hostNameKey = new Key<>("hostname");
-    static Key<String> osNameKey = new Key<>("osName");
-    static Key<String> osKernelKey = new Key<>("osKernel");
-    static Key<Integer> cpuCountKey = new Key<>("cpuCount");
-    static Key<String> cpuModelKey = new Key<>("cpuModel");
-    static Key<Long> hostMemoryTotalKey = new Key<>("totalMemory");
-
-    static final Category<HostInfo> hostInfoCategory = new Category<>("host-info", HostInfo.class,
-            Key.AGENT_ID, hostNameKey, osNameKey, osKernelKey,
-            cpuCountKey, cpuModelKey, hostMemoryTotalKey);
-
     void putHostInfo(HostInfo info);
 
 }
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOCategoryRegistration.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright 2012-2017 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.host.overview.common.internal;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.redhat.thermostat.storage.core.auth.CategoryRegistration;
-
-/**
- * Registers the category used by this maven module. The web storage
- * endpoint only allows categories to be registered which it knows of
- * ahead of time.
- *
- */
-public class HostInfoDAOCategoryRegistration implements CategoryRegistration {
-
-    @Override
-    public Set<String> getCategoryNames() {
-        Set<String> categories = new HashSet<>(1);
-        categories.add(HostInfoDAOImpl.hostInfoCategory.getName());
-        return categories;
-    }
-
-}
-
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.CategoryRegistration	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.redhat.thermostat.host.overview.common.internal.HostInfoDAOCategoryRegistration
\ No newline at end of file
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.redhat.thermostat.host.overview.common.internal.HostInfoDAOImplStatementDescriptorRegistration
\ No newline at end of file
--- a/plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOCategoryRegistrationTest.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012-2017 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.host.overview.common.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.host.overview.common.HostInfoDAO;
-import com.redhat.thermostat.storage.core.auth.CategoryRegistration;
-import com.redhat.thermostat.testutils.ServiceLoaderTest;
-
-public class HostInfoDAOCategoryRegistrationTest extends ServiceLoaderTest<CategoryRegistration> {
-
-    public HostInfoDAOCategoryRegistrationTest() {
-        super(CategoryRegistration.class, STORAGE_SERVICES, HostInfoDAOCategoryRegistration.class);
-    }
-
-    @Test
-    public void registersAllCategories() {
-        HostInfoDAOCategoryRegistration reg = new HostInfoDAOCategoryRegistration();
-        Set<String> categories = reg.getCategoryNames();
-        assertEquals(1, categories.size());
-        assertFalse("null descriptor not allowed", categories.contains(null));
-        assertTrue(categories.contains(HostInfoDAO.hostInfoCategory.getName()));
-    }
-
-}
-
--- a/plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOTest.java	Thu May 25 14:36:44 2017 -0400
@@ -36,8 +36,6 @@
 
 package com.redhat.thermostat.host.overview.common.internal;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
@@ -46,7 +44,6 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
@@ -56,11 +53,9 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.host.overview.common.HostInfoDAO;
 import com.redhat.thermostat.host.overview.common.internal.HostInfoDAOImpl.HttpHelper;
 import com.redhat.thermostat.host.overview.common.internal.HostInfoDAOImpl.JsonHelper;
 import com.redhat.thermostat.host.overview.common.model.HostInfo;
-import com.redhat.thermostat.storage.core.Key;
 
 public class HostInfoDAOTest {
 
@@ -99,20 +94,6 @@
     }
 
     @Test
-    public void testCategory() {
-        assertEquals("host-info", HostInfoDAO.hostInfoCategory.getName());
-        Collection<Key<?>> keys = HostInfoDAO.hostInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<>("agentId")));
-        assertTrue(keys.contains(new Key<String>("hostname")));
-        assertTrue(keys.contains(new Key<String>("osName")));
-        assertTrue(keys.contains(new Key<String>("osKernel")));
-        assertTrue(keys.contains(new Key<String>("cpuModel")));
-        assertTrue(keys.contains(new Key<Integer>("cpuCount")));
-        assertTrue(keys.contains(new Key<Long>("totalMemory")));
-        assertEquals(7, keys.size());
-    }
-
-    @Test
     public void testPutHostInfo() throws Exception {
         HostInfoDAOImpl dao = new HostInfoDAOImpl(httpHelper, jsonHelper);
         dao.activate();
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/dao/AgentInfoDAO.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/AgentInfoDAO.java	Thu May 25 14:36:44 2017 -0400
@@ -41,8 +41,6 @@
 
 import com.redhat.thermostat.annotations.Service;
 import com.redhat.thermostat.storage.core.AgentId;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.model.AgentInformation;
 
 /**
@@ -50,18 +48,6 @@
  */
 @Service
 public interface AgentInfoDAO {
-
-    static final Key<Long> START_TIME_KEY = new Key<>("startTime");
-    static final Key<Long> STOP_TIME_KEY = new Key<>("stopTime");
-    static final Key<Boolean> ALIVE_KEY = new Key<>("alive");
-    static final Key<String> CONFIG_LISTEN_ADDRESS = new Key<>("configListenAddress");
-
-    static final Category<AgentInformation> CATEGORY = new Category<>("agent-config", AgentInformation.class,
-            Key.AGENT_ID,
-            START_TIME_KEY,
-            STOP_TIME_KEY,
-            ALIVE_KEY,
-            CONFIG_LISTEN_ADDRESS);
     
     /**
      * Get information about all known agents.
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/dao/BackendInfoDAO.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/BackendInfoDAO.java	Thu May 25 14:36:44 2017 -0400
@@ -36,32 +36,12 @@
 
 package com.redhat.thermostat.storage.dao;
 
-import java.util.List;
-
 import com.redhat.thermostat.annotations.Service;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.model.BackendInformation;
 
 @Service
 public interface BackendInfoDAO {
 
-    static final Key<String> BACKEND_NAME = new Key<>("name");
-    static final Key<String> BACKEND_DESCRIPTION = new Key<>("description");
-    static final Key<Boolean> IS_ACTIVE = new Key<>("active");
-    static final Key<Boolean> SHOULD_MONITOR_NEW_PROCESSES = new Key<>("observeNewJvm");
-    static final Key<List<Integer>> PIDS_TO_MONITOR = new Key<>("pids");
-    static final Key<Integer> ORDER_VALUE = new Key<>("orderValue");
-
-    static final Category<BackendInformation> CATEGORY = new Category<>("backend-info", BackendInformation.class,
-            Key.AGENT_ID,
-            BACKEND_NAME,
-            BACKEND_DESCRIPTION,
-            IS_ACTIVE,
-            SHOULD_MONITOR_NEW_PROCESSES,
-            PIDS_TO_MONITOR,
-            ORDER_VALUE);
-
     void addBackendInformation(BackendInformation info);
 
     void removeBackendInformation(BackendInformation info);
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/dao/NetworkInterfaceInfoDAO.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/NetworkInterfaceInfoDAO.java	Thu May 25 14:36:44 2017 -0400
@@ -37,20 +37,11 @@
 package com.redhat.thermostat.storage.dao;
 
 import com.redhat.thermostat.annotations.Service;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.model.NetworkInterfaceInfo;
 
 @Service
 public interface NetworkInterfaceInfoDAO {
 
-    static Key<String> ifaceKey = new Key<>("interfaceName");
-    static Key<String> ip4AddrKey = new Key<>("ip4Addr");
-    static Key<String> ip6AddrKey = new Key<>("ip6Addr");
-
-    static final Category<NetworkInterfaceInfo> networkInfoCategory = new Category<>("network-info", NetworkInterfaceInfo.class,
-            Key.AGENT_ID, ifaceKey, ip4AddrKey, ip6AddrKey);
-
     public void putNetworkInterfaceInfo(NetworkInterfaceInfo info);
 }
 
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/dao/VmInfoDAO.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/dao/VmInfoDAO.java	Thu May 25 14:36:44 2017 -0400
@@ -40,40 +40,12 @@
 
 import com.redhat.thermostat.annotations.Service;
 import com.redhat.thermostat.storage.core.AgentId;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.core.VmId;
 import com.redhat.thermostat.storage.model.VmInfo;
-import com.redhat.thermostat.storage.model.VmInfo.KeyValuePair;
 
 @Service
 public interface VmInfoDAO {
 
-    static final Key<Integer> vmPidKey = new Key<>("vmPid");
-    static final Key<String> runtimeVersionKey = new Key<>("javaVersion");
-    static final Key<String> javaHomeKey = new Key<>("javaHome");
-    static final Key<String> mainClassKey = new Key<>("mainClass");
-    static final Key<String> commandLineKey = new Key<>("javaCommandLine");
-    static final Key<String> vmArgumentsKey = new Key<>("vmArguments");
-    static final Key<String> vmNameKey = new Key<>("vmName");
-    static final Key<String> vmInfoKey = new Key<>("vmInfo");
-    static final Key<String> vmVersionKey = new Key<>("vmVersion");
-    static final Key<KeyValuePair[]> propertiesKey = new Key<>("propertiesAsArray");
-    static final Key<KeyValuePair[]> environmentKey = new Key<>("environmentAsArray");
-    static final Key<String[]> librariesKey = new Key<>("loadedNativeLibraries");
-    static final Key<Long> startTimeKey = new Key<>("startTimeStamp");
-    static final Key<Long> stopTimeKey = new Key<>("stopTimeStamp");
-    static final Key<Long> uidKey = new Key<>("uid");
-    static final Key<String> usernameKey = new Key<>("username");
-
-    static final Category<VmInfo> vmInfoCategory = new Category<>("vm-info", VmInfo.class,
-            Key.AGENT_ID, Key.VM_ID, vmPidKey, runtimeVersionKey, javaHomeKey,
-            mainClassKey, commandLineKey,
-            vmArgumentsKey, vmNameKey, vmInfoKey, vmVersionKey,
-            propertiesKey, environmentKey, librariesKey,
-            startTimeKey, stopTimeKey,
-            uidKey, usernameKey);
-
     /** @return {@code null} if no information can be found */
     VmInfo getVmInfo(VmId id);
 
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOImpl.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOImpl.java	Thu May 25 14:36:44 2017 -0400
@@ -68,7 +68,7 @@
     private static final String GATEWAY_PATH = "/backend-info/systems/*/agents/";
     private static final String CONTENT_TYPE = "application/json";
     private static final String GATEWAY_QUERY = "?q=";
-    private static final String DELETE_QUERY_PARAM = BACKEND_NAME.getName() + "==";
+    private static final String DELETE_QUERY_PARAM = "name==";
 
     private final HttpHelper httpHelper;
     private final JsonHelper jsonHelper;
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistration.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012-2017 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.storage.internal.dao;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.redhat.thermostat.storage.core.auth.CategoryRegistration;
-import com.redhat.thermostat.storage.dao.AgentInfoDAO;
-import com.redhat.thermostat.storage.dao.BackendInfoDAO;
-import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO;
-import com.redhat.thermostat.storage.dao.VmInfoDAO;
-
-/**
- * Registers the category used by this maven module. The web storage
- * endpoint only allows categories to be registered which it knows of
- * ahead of time.
- *
- */
-public class DAOImplCategoryRegistration implements CategoryRegistration {
-
-    @Override
-    public Set<String> getCategoryNames() {
-        Set<String> categories = new HashSet<>(5);
-        categories.add(AgentInfoDAO.CATEGORY.getName());
-        categories.add(VmInfoDAO.vmInfoCategory.getName());
-        categories.add(BackendInfoDAO.CATEGORY.getName());
-        categories.add(NetworkInterfaceInfoDAO.networkInfoCategory.getName());
-        return categories;
-    }
-
-}
-
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/DAOImplStatementDescriptorRegistration.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright 2012-2017 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.storage.internal.dao;
-
-import java.util.Collections;
-import java.util.Set;
-
-import com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration;
-
-/**
- * Registers prepared queries issued by this maven module
- * via various DAOs.
- *
- */
-public class DAOImplStatementDescriptorRegistration implements
-        StatementDescriptorRegistration {
-    
-    @Override
-    public Set<String> getStatementDescriptors() {
-        return Collections.emptySet(); // TODO Remove once plugins no longer depend on this
-    }
-
-}
-
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOImpl.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOImpl.java	Thu May 25 14:36:44 2017 -0400
@@ -69,7 +69,7 @@
     private static final String GATEWAY_PATH = "/network-info/systems/*/agents/";
     private static final String CONTENT_TYPE = "application/json";
     private static final String GATEWAY_QUERY = "?q=";
-    private static final String QUERY_INTERFACE_PARAM = ifaceKey.getName() + "==";
+    private static final String QUERY_INTERFACE_PARAM = "interfaceName==";
     
     private final HttpHelper httpHelper;
     private final JsonHelper jsonHelper;
--- a/storage/core/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.CategoryRegistration	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.redhat.thermostat.storage.internal.dao.DAOImplCategoryRegistration
\ No newline at end of file
--- a/storage/core/src/main/resources/META-INF/services/com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.redhat.thermostat.storage.internal.dao.DAOImplStatementDescriptorRegistration
\ No newline at end of file
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/CategoryAdapterTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/CategoryAdapterTest.java	Thu May 25 14:36:44 2017 -0400
@@ -36,27 +36,12 @@
 
 package com.redhat.thermostat.storage.core;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.junit.Test;
 
-import com.redhat.thermostat.storage.dao.AgentInfoDAO;
-import com.redhat.thermostat.storage.model.AgentInformation;
-import com.redhat.thermostat.storage.model.AggregateCount;
-
 public class CategoryAdapterTest {
-
-    @Test
-    public void canAdaptToAggregateResultDataClass() {
-        CategoryAdapter<AgentInformation, AggregateCount> adapter = new CategoryAdapter<>(AgentInfoDAO.CATEGORY);
-        Category<AggregateCount> aggregateCountCat = adapter.getAdapted(AggregateCount.class);
-        assertEquals(AggregateCount.class, aggregateCountCat.getDataClass());
-        assertEquals(AgentInfoDAO.CATEGORY.getName(), aggregateCountCat.getName());
-        assertFalse(AgentInfoDAO.CATEGORY.equals(aggregateCountCat));
-    }
     
     @Test
     public void canCreateAdapterFromNull() {
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/AdaptedCategoryTest.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright 2012-2017 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.storage.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.storage.core.Key;
-import com.redhat.thermostat.storage.dao.AgentInfoDAO;
-import com.redhat.thermostat.storage.dao.VmInfoDAO;
-import com.redhat.thermostat.storage.model.AgentInformation;
-import com.redhat.thermostat.storage.model.AggregateCount;
-import com.redhat.thermostat.storage.model.AggregateResult;
-import com.redhat.thermostat.storage.model.VmInfo;
-
-public class AdaptedCategoryTest {
-
-    @Test
-    public void testEquals() {
-        AdaptedCategory<AggregateCount, AgentInformation> cat = new AdaptedCategory<>(AgentInfoDAO.CATEGORY, AggregateCount.class);
-        assertFalse(cat.equals(AgentInfoDAO.CATEGORY));
-        // equals self
-        assertEquals(cat, cat);
-        // not equal to any other category
-        assertFalse(VmInfoDAO.vmInfoCategory.equals(cat));
-    }
-    
-    @Test
-    public void testHashCode() {
-        AdaptedCategory<AggregateCount, AgentInformation> cat = new AdaptedCategory<>(AgentInfoDAO.CATEGORY, AggregateCount.class);
-        assertTrue("Adapted and original must have different hash code",
-                cat.hashCode() != AgentInfoDAO.CATEGORY.hashCode());
-    }
-    
-    @Test
-    public void getDataClass() {
-        AdaptedCategory<AggregateCount, AgentInformation> cat = new AdaptedCategory<>(AgentInfoDAO.CATEGORY, AggregateCount.class);
-        assertEquals(AggregateCount.class, cat.getDataClass());
-        assertTrue(AggregateResult.class.isAssignableFrom(cat.getDataClass()));
-    }
-    
-    @Test
-    public void keysAreImmutable() {
-        AdaptedCategory<AggregateCount, AgentInformation> cat = new AdaptedCategory<>(AgentInfoDAO.CATEGORY, AggregateCount.class);
-        try {
-            cat.getKeys().add(new Key<>("foo"));
-            fail("keys need to be immutable");
-        } catch (UnsupportedOperationException e) {
-            // pass
-        }
-    }
-    
-    @Test
-    public void adaptNonAggregateDataClass() {
-        try {
-            new AdaptedCategory<>(AgentInfoDAO.CATEGORY, VmInfo.class);
-        } catch (IllegalArgumentException e) {
-            // pass
-            assertTrue(e.getMessage().contains("Can only adapt to aggregate results"));
-        }
-    }
-    
-}
-
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/AgentInfoDAOTest.java	Thu May 25 14:36:44 2017 -0400
@@ -37,7 +37,6 @@
 package com.redhat.thermostat.storage.internal.dao;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyString;
@@ -47,7 +46,6 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
@@ -58,8 +56,6 @@
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.dao.AgentInfoDAO;
 import com.redhat.thermostat.storage.internal.dao.AgentInfoDAOImpl.AgentInformationUpdate;
 import com.redhat.thermostat.storage.internal.dao.AgentInfoDAOImpl.HttpHelper;
@@ -103,32 +99,6 @@
     }
 
     @Test
-    public void verifyCategoryName() {
-        Category<AgentInformation> category = AgentInfoDAO.CATEGORY;
-        assertEquals("agent-config", category.getName());
-    }
-
-    @Test
-    public void verifyKeyNames() {
-        assertEquals("agentId", Key.AGENT_ID.getName());
-        assertEquals("alive", AgentInfoDAO.ALIVE_KEY.getName());
-        assertEquals("startTime", AgentInfoDAO.START_TIME_KEY.getName());
-        assertEquals("stopTime", AgentInfoDAO.STOP_TIME_KEY.getName());
-        assertEquals("configListenAddress", AgentInfoDAO.CONFIG_LISTEN_ADDRESS.getName());
-    }
-
-    @Test
-    public void verifyCategoryHasAllKeys() {
-        Collection<Key<?>> keys = AgentInfoDAO.CATEGORY.getKeys();
-
-        assertTrue(keys.contains(Key.AGENT_ID));
-        assertTrue(keys.contains(AgentInfoDAO.ALIVE_KEY));
-        assertTrue(keys.contains(AgentInfoDAO.START_TIME_KEY));
-        assertTrue(keys.contains(AgentInfoDAO.STOP_TIME_KEY));
-        assertTrue(keys.contains(AgentInfoDAO.CONFIG_LISTEN_ADDRESS));
-    }
-
-    @Test
     public void verifyAddAgentInformation() throws Exception {
         AgentInfoDAO dao = new AgentInfoDAOImpl(httpHelper, jsonHelper);
 
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/BackendInfoDAOTest.java	Thu May 25 14:36:44 2017 -0400
@@ -36,8 +36,6 @@
 
 package com.redhat.thermostat.storage.internal.dao;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
@@ -46,7 +44,6 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
@@ -56,8 +53,6 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.dao.BackendInfoDAO;
 import com.redhat.thermostat.storage.internal.dao.BackendInfoDAOImpl.HttpHelper;
 import com.redhat.thermostat.storage.internal.dao.BackendInfoDAOImpl.JsonHelper;
@@ -100,26 +95,6 @@
         jsonHelper = mock(JsonHelper.class);
         when(jsonHelper.toJson(anyListOf(BackendInformation.class))).thenReturn(SOME_JSON);
     }
-    
-    @Test
-    public void verifyCategoryName() {
-        Category<BackendInformation> c = BackendInfoDAO.CATEGORY;
-        assertEquals("backend-info", c.getName());
-    }
-
-    @Test
-    public void verifyCategoryHasAllKeys() {
-        Category<BackendInformation> c = BackendInfoDAO.CATEGORY;
-        Collection<Key<?>> keys = c.getKeys();
-
-        assertTrue(keys.contains(Key.AGENT_ID));
-        assertTrue(keys.contains(BackendInfoDAO.BACKEND_NAME));
-        assertTrue(keys.contains(BackendInfoDAO.BACKEND_DESCRIPTION));
-        assertTrue(keys.contains(BackendInfoDAO.IS_ACTIVE));
-        assertTrue(keys.contains(BackendInfoDAO.PIDS_TO_MONITOR));
-        assertTrue(keys.contains(BackendInfoDAO.SHOULD_MONITOR_NEW_PROCESSES));
-        assertTrue(keys.contains(BackendInfoDAO.ORDER_VALUE));
-    }
 
     @Test
     public void verifyAddBackendInformation() throws Exception {
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/DAOImplCategoryRegistrationTest.java	Thu May 25 14:17:22 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright 2012-2017 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.storage.internal.dao;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.storage.core.auth.CategoryRegistration;
-import com.redhat.thermostat.storage.dao.AgentInfoDAO;
-import com.redhat.thermostat.storage.dao.BackendInfoDAO;
-import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO;
-import com.redhat.thermostat.storage.dao.VmInfoDAO;
-import com.redhat.thermostat.testutils.ServiceLoaderTest;
-
-public class DAOImplCategoryRegistrationTest extends ServiceLoaderTest<CategoryRegistration> {
-
-    public DAOImplCategoryRegistrationTest() {
-        super(CategoryRegistration.class, NO_EXTRA_SERVICES, DAOImplCategoryRegistration.class);
-    }
-
-    @Test
-    public void registersAllCategories() {
-        DAOImplCategoryRegistration reg = new DAOImplCategoryRegistration();
-        Set<String> categories = reg.getCategoryNames();
-        assertEquals(4, categories.size());
-        assertFalse("null descriptor not allowed", categories.contains(null));
-        assertTrue(categories.contains(VmInfoDAO.vmInfoCategory.getName()));
-        assertTrue(categories.contains(AgentInfoDAO.CATEGORY.getName()));
-        assertTrue(categories.contains(NetworkInterfaceInfoDAO.networkInfoCategory.getName()));
-        assertTrue(categories.contains(BackendInfoDAO.CATEGORY.getName()));
-    }
-
-}
-
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/NetworkInterfaceInfoDAOTest.java	Thu May 25 14:36:44 2017 -0400
@@ -37,7 +37,6 @@
 package com.redhat.thermostat.storage.internal.dao;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyString;
@@ -49,7 +48,6 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -62,7 +60,6 @@
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO;
 import com.redhat.thermostat.storage.internal.dao.NetworkInterfaceInfoDAOImpl.HttpHelper;
 import com.redhat.thermostat.storage.internal.dao.NetworkInterfaceInfoDAOImpl.JsonHelper;
@@ -110,20 +107,7 @@
         when(jsonHelper.fromJson(EMPTY_JSON)).thenReturn(emptyList);
         when(jsonHelper.fromJson(SOME_JSON)).thenReturn(Arrays.asList(info));
     }
-    
-    @Test
-    public void testCategory() {
-        Collection<Key<?>> keys;
 
-        assertEquals("network-info", NetworkInterfaceInfoDAO.networkInfoCategory.getName());
-        keys = NetworkInterfaceInfoDAO.networkInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<>("agentId")));
-        assertTrue(keys.contains(new Key<String>("interfaceName")));
-        assertTrue(keys.contains(new Key<String>("ip4Addr")));
-        assertTrue(keys.contains(new Key<String>("ip6Addr")));
-        assertEquals(4, keys.size());
-    }
-    
     @Test
     public void testPutNetworkInterfaceInfoAdd() throws Exception {
         NetworkInterfaceInfoDAO dao = new NetworkInterfaceInfoDAOImpl(httpHelper, jsonHelper);
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOTest.java	Thu May 25 14:17:22 2017 -0400
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/internal/dao/VmInfoDAOTest.java	Thu May 25 14:36:44 2017 -0400
@@ -37,7 +37,6 @@
 package com.redhat.thermostat.storage.internal.dao;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyString;
@@ -47,7 +46,6 @@
 import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -60,13 +58,11 @@
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.dao.VmInfoDAO;
 import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl.HttpHelper;
 import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl.JsonHelper;
 import com.redhat.thermostat.storage.internal.dao.VmInfoDAOImpl.VmInfoUpdate;
 import com.redhat.thermostat.storage.model.VmInfo;
-import com.redhat.thermostat.storage.model.VmInfo.KeyValuePair;
 
 public class VmInfoDAOTest {
 
@@ -119,31 +115,6 @@
         when(jsonHelper.toJson(anyListOf(VmInfo.class))).thenReturn(SOME_JSON);
         when(jsonHelper.toJson(any(VmInfoUpdate.class))).thenReturn(SOME_OTHER_JSON);
     }
-    
-    @Test
-    public void testCategory() {
-        assertEquals("vm-info", VmInfoDAO.vmInfoCategory.getName());
-        Collection<Key<?>> keys = VmInfoDAO.vmInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<>("agentId")));
-        assertTrue(keys.contains(new Key<Integer>("vmId")));
-        assertTrue(keys.contains(new Key<Integer>("vmPid")));
-        assertTrue(keys.contains(new Key<String>("javaVersion")));
-        assertTrue(keys.contains(new Key<String>("javaHome")));
-        assertTrue(keys.contains(new Key<String>("mainClass")));
-        assertTrue(keys.contains(new Key<String>("javaCommandLine")));
-        assertTrue(keys.contains(new Key<String>("vmArguments")));
-        assertTrue(keys.contains(new Key<String>("vmName")));
-        assertTrue(keys.contains(new Key<String>("vmInfo")));
-        assertTrue(keys.contains(new Key<String>("vmVersion")));
-        assertTrue(keys.contains(new Key<KeyValuePair[]>("propertiesAsArray")));
-        assertTrue(keys.contains(new Key<KeyValuePair[]>("environmentAsArray")));
-        assertTrue(keys.contains(new Key<String[]>("loadedNativeLibraries")));
-        assertTrue(keys.contains(new Key<Long>("startTimeStamp")));
-        assertTrue(keys.contains(new Key<Long>("stopTimeStamp")));
-        assertTrue(keys.contains(new Key<Long>("uid")));
-        assertTrue(keys.contains(new Key<Long>("username")));
-        assertEquals(18, keys.size());
-    }
 
     @Test
     public void testPutVmInfo() throws Exception {