com.scit.sling.test
Class MockAdapter
java.lang.Object
com.scit.sling.test.MockAdapter
public class MockAdapter
- extends Object
A Mock Adaptable that can be easily setup
Method Summary |
<AdapterType>
AdapterType |
|
adaptTo(Object adaptable,
Class<AdapterType> type)
|
|
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 |
MockAdapter
public MockAdapter()
MockAdapter
public MockAdapter(Map<Class<?>,Object> adaptables,
Collection<org.apache.sling.api.adapter.AdapterFactory> factories)
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.classtarget
- 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.