com.scit.sling.test
Class MockAdapter

java.lang.Object
  extended by com.scit.sling.test.MockAdapter

public class MockAdapter
extends Object

A Mock Adaptable that can be easily setup


Constructor Summary
MockAdapter()
           
MockAdapter(Map<Class<?>,Object> adaptables, Collection<org.apache.sling.api.adapter.AdapterFactory> factories)
           
 
Method Summary
<AdapterType>
AdapterType
adaptTo(Object adaptable, Class<AdapterType> type)
           
<AdapterType>
void
addAdaptable(Class<AdapterType> type, AdapterType target)
          Setup the #adaptTo(Class) to be able to adapt to a specific target.
 void setAdapterFactories(Collection<org.apache.sling.api.adapter.AdapterFactory> adapterFactory)
          Add an AdapterFactory for custom adaptations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockAdapter

public MockAdapter()

MockAdapter

public MockAdapter(Map<Class<?>,Object> adaptables,
                   Collection<org.apache.sling.api.adapter.AdapterFactory> factories)
Method Detail

addAdaptable

public <AdapterType> void addAdaptable(Class<AdapterType> type,
                                       AdapterType target)
Setup the #adaptTo(Class) to be able to adapt to a specific target. See also, setAdapterFactories(Collection) if you want a test a factory instead.

Parameters:
type - the Class object of the target type, such as Node.class
target - the adapter target that will be returned if the #adaptTo(Class) is called with type

setAdapterFactories

public void setAdapterFactories(Collection<org.apache.sling.api.adapter.AdapterFactory> adapterFactory)
Add an AdapterFactory for custom adaptations

Parameters:
adapterFactory -

adaptTo

public <AdapterType> AdapterType adaptTo(Object adaptable,
                                         Class<AdapterType> type)


Copyright © 2013 Southern Cross IT. All rights reserved.