@Test public void testGetHostAttributes() throws Exception { HostEntity hostEntity = createNiceMock(HostEntity.class); HostStateEntity hostStateEntity = createNiceMock(HostStateEntity.class); HostDAO hostDAO = createNiceMock(HostDAO.class); HostStateDAO hostStateDAO = createNiceMock(HostStateDAO.class); Gson gson = new Gson(); expect(hostEntity.getHostAttributes()).andReturn("{\"foo\": \"aaa\", \"bar\":\"bbb\"}").anyTimes(); expect(hostEntity.getHostId()).andReturn(1L).anyTimes(); expect(hostEntity.getHostName()).andReturn("host1").anyTimes(); expect(hostEntity.getHostStateEntity()).andReturn(hostStateEntity).anyTimes(); expect(hostDAO.findById(1L)).andReturn(hostEntity).atLeastOnce(); replayAll(); HostImpl host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO); Map<String, String> hostAttributes = host.getHostAttributes(); assertEquals("aaa", hostAttributes.get("foo")); assertEquals("bbb", hostAttributes.get("bar")); host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO); hostAttributes = host.getHostAttributes(); assertEquals("aaa", hostAttributes.get("foo")); assertEquals("bbb", hostAttributes.get("bar")); verifyAll(); }
@Override public Map<String, String> getHostAttributes() { return gson.fromJson(getHostEntity().getHostAttributes(), hostAttributesType); }
HostImpl implements Host { @Override public Map<String, String> getHostAttributes() { return gson.fromJson(getHostEntity().getHostAttributes(), hostAttributesType); } }
HostImpl implements Host { @Override public Map<String, String> getHostAttributes() { return gson.fromJson(getHostEntity().getHostAttributes(), hostAttributesType); } @Inject  HostImpl(@Assisted HostEntity hostEntity, Gson gson, HostDAO hostDAO, HostStateDAO hostStateDAO); }
HostImpl implements Host { @Override public Map<String, String> getHostAttributes() { return gson.fromJson(getHostEntity().getHostAttributes(), hostAttributesType); } @Inject  HostImpl(@Assisted HostEntity hostEntity, Gson gson, HostDAO hostDAO, HostStateDAO hostStateDAO); @Override int compareTo(Object o); @Override @Transactional void importHostInfo(HostInfo hostInfo); @Override void setLastAgentEnv(AgentEnv env); @Override AgentEnv getLastAgentEnv(); @Override HostState getState(); @Override void setState(HostState state); @Override void handleEvent(HostEvent event); @Override String getHostName(); @Override Long getHostId(); @Override Integer getCurrentPingPort(); @Override void setCurrentPingPort(Integer currentPingPort); @Override void setPublicHostName(String hostName); @Override String getPublicHostName(); @Override String getIPv4(); @Override void setIPv4(String ip); @Override String getIPv6(); @Override void setIPv6(String ip); @Override int getCpuCount(); @Override void setCpuCount(int cpuCount); @Override int getPhCpuCount(); @Override void setPhCpuCount(int phCpuCount); @Override long getTotalMemBytes(); @Override void setTotalMemBytes(long totalMemBytes); @Override long getAvailableMemBytes(); @Override void setAvailableMemBytes(long availableMemBytes); @Override String getOsArch(); @Override void setOsArch(String osArch); @Override String getOsInfo(); @Override void setOsInfo(String osInfo); @Override String getOsType(); @Override void setOsType(String osType); @Override String getOsFamily(); @Override String getOSFamilyFromHostAttributes(Map<String, String> hostAttributes); @Override List<DiskInfo> getDisksInfo(); @Override void setDisksInfo(List<DiskInfo> disksInfo); @Override RecoveryReport getRecoveryReport(); @Override void setRecoveryReport(RecoveryReport recoveryReport); @Override HostHealthStatus getHealthStatus(); @Override void setHealthStatus(HostHealthStatus healthStatus); @Override String getPrefix(); @Override void setPrefix(String prefix); @Override Map<String, String> getHostAttributes(); @Override void setHostAttributes(Map<String, String> hostAttributes); @Override String getRackInfo(); @Override void setRackInfo(String rackInfo); @Override long getLastRegistrationTime(); @Override void setLastRegistrationTime(long lastRegistrationTime); @Override long getLastHeartbeatTime(); @Override void setLastHeartbeatTime(long lastHeartbeatTime); @Override AgentVersion getAgentVersion(); @Override void setAgentVersion(AgentVersion agentVersion); @Override long getTimeInState(); @Override void setTimeInState(long timeInState); @Override String getStatus(); @Override void setStatus(String status); @Override boolean equals(Object o); @Override int hashCode(); @Override HostResponse convertToResponse(); @Override @Transactional boolean addDesiredConfig(long clusterId, boolean selected, String user, Config config); @Override Map<String, DesiredConfig> getDesiredConfigs(long clusterId); @Override Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster,
      Map<String, DesiredConfig> clusterDesiredConfigs); @Override void setMaintenanceState(long clusterId, MaintenanceState state); @Override MaintenanceState getMaintenanceState(long clusterId); @Override List<HostVersionEntity> getAllHostVersions(); @Override HostEntity getHostEntity(); HostStateEntity getHostStateEntity(); @Override boolean hasComponentsAdvertisingVersions(StackId stackId); }
HostImpl implements Host { @Override public Map<String, String> getHostAttributes() { return gson.fromJson(getHostEntity().getHostAttributes(), hostAttributesType); } @Inject  HostImpl(@Assisted HostEntity hostEntity, Gson gson, HostDAO hostDAO, HostStateDAO hostStateDAO); @Override int compareTo(Object o); @Override @Transactional void importHostInfo(HostInfo hostInfo); @Override void setLastAgentEnv(AgentEnv env); @Override AgentEnv getLastAgentEnv(); @Override HostState getState(); @Override void setState(HostState state); @Override void handleEvent(HostEvent event); @Override String getHostName(); @Override Long getHostId(); @Override Integer getCurrentPingPort(); @Override void setCurrentPingPort(Integer currentPingPort); @Override void setPublicHostName(String hostName); @Override String getPublicHostName(); @Override String getIPv4(); @Override void setIPv4(String ip); @Override String getIPv6(); @Override void setIPv6(String ip); @Override int getCpuCount(); @Override void setCpuCount(int cpuCount); @Override int getPhCpuCount(); @Override void setPhCpuCount(int phCpuCount); @Override long getTotalMemBytes(); @Override void setTotalMemBytes(long totalMemBytes); @Override long getAvailableMemBytes(); @Override void setAvailableMemBytes(long availableMemBytes); @Override String getOsArch(); @Override void setOsArch(String osArch); @Override String getOsInfo(); @Override void setOsInfo(String osInfo); @Override String getOsType(); @Override void setOsType(String osType); @Override String getOsFamily(); @Override String getOSFamilyFromHostAttributes(Map<String, String> hostAttributes); @Override List<DiskInfo> getDisksInfo(); @Override void setDisksInfo(List<DiskInfo> disksInfo); @Override RecoveryReport getRecoveryReport(); @Override void setRecoveryReport(RecoveryReport recoveryReport); @Override HostHealthStatus getHealthStatus(); @Override void setHealthStatus(HostHealthStatus healthStatus); @Override String getPrefix(); @Override void setPrefix(String prefix); @Override Map<String, String> getHostAttributes(); @Override void setHostAttributes(Map<String, String> hostAttributes); @Override String getRackInfo(); @Override void setRackInfo(String rackInfo); @Override long getLastRegistrationTime(); @Override void setLastRegistrationTime(long lastRegistrationTime); @Override long getLastHeartbeatTime(); @Override void setLastHeartbeatTime(long lastHeartbeatTime); @Override AgentVersion getAgentVersion(); @Override void setAgentVersion(AgentVersion agentVersion); @Override long getTimeInState(); @Override void setTimeInState(long timeInState); @Override String getStatus(); @Override void setStatus(String status); @Override boolean equals(Object o); @Override int hashCode(); @Override HostResponse convertToResponse(); @Override @Transactional boolean addDesiredConfig(long clusterId, boolean selected, String user, Config config); @Override Map<String, DesiredConfig> getDesiredConfigs(long clusterId); @Override Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster,
      Map<String, DesiredConfig> clusterDesiredConfigs); @Override void setMaintenanceState(long clusterId, MaintenanceState state); @Override MaintenanceState getMaintenanceState(long clusterId); @Override List<HostVersionEntity> getAllHostVersions(); @Override HostEntity getHostEntity(); HostStateEntity getHostStateEntity(); @Override boolean hasComponentsAdvertisingVersions(StackId stackId);  }