org.rhq.test.arquillian
Class FakeServerInventory

java.lang.Object
  extended by org.rhq.test.arquillian.FakeServerInventory

public class FakeServerInventory
extends Object

This class represents a server side database store of the inventory for the purposes of the unit tests that need to mock out the server functionality.

The methods are not exhaustive and were added on as-needed basis. If this class doesn't cover what you need, either add the functionality directly to it, subclass or roll your own. It is only meant as a helper.

This impl uses mockito for defining the answers to various calls.

Author:
Lukas Krejci

Nested Class Summary
static class FakeServerInventory.CompleteDiscoveryChecker
          You can FakeServerInventory.CompleteDiscoveryChecker.waitForDiscoveryComplete() on an instance of this class for the complete discovery to finish in case your fake server commits some resources (which starts off asynchronous discovery of children).
 
Constructor Summary
FakeServerInventory()
           
FakeServerInventory(boolean failing)
           
 
Method Summary
 org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.MergeResourceResponse> addResource()
           
 org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.ResourceSyncInfo> clearPlatform()
           
 FakeServerInventory.CompleteDiscoveryChecker createAsyncDiscoveryCompletionChecker(int expectedResourceTreeDepth)
           
 Set<org.rhq.core.domain.resource.Resource> findResourcesByType(org.rhq.core.domain.resource.ResourceType type)
           
 org.mockito.stubbing.Answer<Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest>> getLatestSchedulesForResourceIds()
           
 org.mockito.stubbing.Answer<Set<org.rhq.core.domain.resource.Resource>> getResources()
           
 Map<String,org.rhq.core.domain.resource.Resource> getResourceStore()
           
 int getResourceTreeDepth()
           
 boolean isFailing()
           
 boolean isFailUpgrade()
           
 org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.ResourceSyncInfo> mergeInventoryReport(org.rhq.core.domain.resource.InventoryStatus requiredInventoryStatus)
           
 org.mockito.stubbing.Answer<Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest>> postProcessNewlyCommittedResources()
           
 void prepopulateInventory(org.rhq.core.domain.resource.Resource platform, Collection<org.rhq.core.domain.resource.Resource> topLevelServers)
           
 void removeResource(org.rhq.core.domain.resource.Resource r)
           
 void setFailing(boolean failing)
           
 void setFailUpgrade(boolean failUpgrade)
           
 org.mockito.stubbing.Answer<Void> setResourceError()
           
 org.mockito.stubbing.Answer<Set<org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse>> upgradeResources()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakeServerInventory

public FakeServerInventory()

FakeServerInventory

public FakeServerInventory(boolean failing)
Method Detail

prepopulateInventory

public void prepopulateInventory(org.rhq.core.domain.resource.Resource platform,
                                 Collection<org.rhq.core.domain.resource.Resource> topLevelServers)

createAsyncDiscoveryCompletionChecker

public FakeServerInventory.CompleteDiscoveryChecker createAsyncDiscoveryCompletionChecker(int expectedResourceTreeDepth)

addResource

public org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.MergeResourceResponse> addResource()

mergeInventoryReport

public org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.ResourceSyncInfo> mergeInventoryReport(org.rhq.core.domain.resource.InventoryStatus requiredInventoryStatus)

getResourceTreeDepth

public int getResourceTreeDepth()

clearPlatform

public org.mockito.stubbing.Answer<org.rhq.core.domain.discovery.ResourceSyncInfo> clearPlatform()

setResourceError

public org.mockito.stubbing.Answer<Void> setResourceError()

upgradeResources

public org.mockito.stubbing.Answer<Set<org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse>> upgradeResources()

getResources

public org.mockito.stubbing.Answer<Set<org.rhq.core.domain.resource.Resource>> getResources()

getLatestSchedulesForResourceIds

public org.mockito.stubbing.Answer<Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest>> getLatestSchedulesForResourceIds()

postProcessNewlyCommittedResources

public org.mockito.stubbing.Answer<Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest>> postProcessNewlyCommittedResources()

isFailing

public boolean isFailing()

setFailing

public void setFailing(boolean failing)

isFailUpgrade

public boolean isFailUpgrade()

setFailUpgrade

public void setFailUpgrade(boolean failUpgrade)

findResourcesByType

public Set<org.rhq.core.domain.resource.Resource> findResourcesByType(org.rhq.core.domain.resource.ResourceType type)

removeResource

public void removeResource(org.rhq.core.domain.resource.Resource r)

getResourceStore

public Map<String,org.rhq.core.domain.resource.Resource> getResourceStore()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.