Previous Topic: Sample Connector Interface ImplementationNext Topic: Create Connector Policy


Mock Domain Manager and Sample Data

A connector integrates with a domain manager to retrieve data. The Sample connector uses a mock domain manager, called the mock MDR, to simulate data creation and event generation. Even when you are building a custom connector to integrate with a real domain manager, in some cases you cannot automate unit tests with the actual domain manager. In this case, you can use the mock MDR interfaces to populate your connector with sample data for testing purposes.

The Sample connector contains the following interfaces for developing or using a mock domain manager:

com.ca.usm.ucf.MyMDR

Contains method declarations to implement a mock domain manager. This interface lets you switch between retrieving mock data and real data. Two implementations of MyMDR are included in the Sample connector: MockMDR and MyMDRImpl. Since the Sample connector always uses a mock domain manager (implemented in MockMDR.java), the implementation of retrieving data from the real domain manager is merely a placeholder (MyMDRImpl.java).

com.ca.usm.ucf.MockMDR

Contains method declarations for a full implementation of a mock domain manager by the Sample connector. The Sample connector uses this interface and the provided sample data as its primary data repository. You can use this class as the mock domain manager for your custom connector, but you must modify the methods in this class so that the mock domain manager and sample data mirrors the integration method and data of your domain manager.

com.ca.usm.ucf.MyMDRImpl

Contains method declarations for maintaining a shell of the real domain manager instance. All methods in this class throw an exception indicating that the operation is not supported because the Sample connector does not have a real domain manager. Any custom connector would have to replace the method implementation in this class with the code to access the real domain manager.

Using a mock domain manager in a custom connector is optional. If you want to do so, you can use the MockMDR interface to create a mock domain manager that simulates data from your domain manager. See the code in the MyMDR interface for an example of how the Sample connector uses MockMDR to create its data repository.

The Sample connector configuration contains a mockMode parameter that controls whether it is retrieving mock data. Because the Sample connector can only retrieve mock data, this parameter is true by default. If you create a mock domain manager for your custom connector, you can include this parameter as false by default, so that you can switch to mock data whenever necessary.