com.silverpeas.pdc.web
Class PdcTestResources

java.lang.Object
  extended by com.silverpeas.web.TestResources
      extended by com.silverpeas.pdc.web.PdcTestResources
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Named(value="testRESTResources")
public class PdcTestResources
extends TestResources

Resources required by the unit tests on the PdC web resources. It manages all of the resources required by the tests.


Field Summary
static String JAVA_PACKAGE
          Java package in which are defined the web resources and their representation (web entities).
static String SPRING_CONTEXT
          The IoC context within which the tests should be ran.
 
Fields inherited from class com.silverpeas.web.TestResources
DEFAULT_DOMAIN, DEFAULT_LANGUAGE, TEST_RESOURCES_NAME, USER_ID_IN_TEST
 
Constructor Summary
PdcTestResources()
           
 
Method Summary
 UserThesaurusHolder aThesaurusHolderFor(UserDetail user)
          Gets a holder of thesaurus for the specified user.
 void enableThesaurus()
          Enables the thesaurus for the users used in the tests.
 List<Axis> getAxisInPdC()
           
 List<UsedAxis> getAxisUsedInClassification()
           
 ContentManager getContentManager()
          Gets the manager of resource's content used in tests.
 OrganisationController getOrganisationController()
          Gets the organisation controller used in tests.
 PdcClassification getPdcClassification()
          Gets the current PdC classification used in the test.
 PdcClassificationService getPdcClassificationServiceMock()
           
 PdcBm getPdcService()
          Gets the PdC business service used in tests.
 PdcClassification getPredefinedClassification(String nodeId, String componentId)
           
 void save(PdcClassification classification)
          Saves the specified PdC classification in the current test context.
 void savePredefined(PdcClassification classification)
          Uses the pre-registered behaviour of the mock for the predefined classification saving.
 String toJSON(PdcClassificationEntity classification)
           
 PdcClassificationEntity toWebEntity(PdcClassification classification, UserDetail forUser)
          Converts the specified classification of a resource on the PdC to its web representation (web entity).
 
Methods inherited from class com.silverpeas.web.TestResources
aUser, aUserNamed, getAccessControllerMock, getApplicationContext, getOrganizationControllerMock, getPersonalizationServiceMock, getSessionManagerMock, getSpaceAccessControllerMock, getTestResources, getTokenServiceMock, registerUser, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_PACKAGE

public static final String JAVA_PACKAGE
Java package in which are defined the web resources and their representation (web entities).

See Also:
Constant Field Values

SPRING_CONTEXT

public static final String SPRING_CONTEXT
The IoC context within which the tests should be ran.

See Also:
Constant Field Values
Constructor Detail

PdcTestResources

public PdcTestResources()
Method Detail

getPdcService

public PdcBm getPdcService()
Gets the PdC business service used in tests.

Returns:
a PdcBm object.

getContentManager

public ContentManager getContentManager()
Gets the manager of resource's content used in tests. The returned content manager instance is a mock, so you can register with it some expected behaviours.

Returns:
a ContentManager instance.

getOrganisationController

public OrganisationController getOrganisationController()
Gets the organisation controller used in tests. The returned organisation controller instance is a mock, so you can register with it some expected behaviours.

Returns:
an organisation controller instance.

aThesaurusHolderFor

public UserThesaurusHolder aThesaurusHolderFor(UserDetail user)
Gets a holder of thesaurus for the specified user.

Parameters:
user - the user for which a thesaurus holder should be get.
Returns:
a UserThesaurusHolder instance.

save

public void save(PdcClassification classification)
Saves the specified PdC classification in the current test context.

Parameters:
classification - the classification on which the test will work.

savePredefined

public void savePredefined(PdcClassification classification)
Uses the pre-registered behaviour of the mock for the predefined classification saving.

Parameters:
classification - the classification to save.

getPredefinedClassification

public PdcClassification getPredefinedClassification(String nodeId,
                                                     String componentId)

getPdcClassification

public PdcClassification getPdcClassification()
Gets the current PdC classification used in the test.

Returns:
the PdC classification in use in the test or null if no classification were saved.

getAxisUsedInClassification

public List<UsedAxis> getAxisUsedInClassification()

getAxisInPdC

public List<Axis> getAxisInPdC()

toWebEntity

public PdcClassificationEntity toWebEntity(PdcClassification classification,
                                           UserDetail forUser)
                                    throws ThesaurusException
Converts the specified classification of a resource on the PdC to its web representation (web entity).

Parameters:
classification - the PdC classification of a resource.
forUser - for whom user the web entity should be built.
Returns:
the web entity representing the specified PdC classification and for the specified user.
Throws:
ThesaurusException - if an error olean ccurs while settings the synonyms.

toJSON

public String toJSON(PdcClassificationEntity classification)

enableThesaurus

public void enableThesaurus()
Enables the thesaurus for the users used in the tests. Once enabled, the synonyms for each value of the PdC axis will be fetched from the users thesaurus.


getPdcClassificationServiceMock

public PdcClassificationService getPdcClassificationServiceMock()


Copyright © 2016 Silverpeas. All Rights Reserved.