use of com.openmeap.util.MockHttpRequestExecuter in project OpenMEAP by OpenMEAP.
the class ModelServiceRefreshNotifierTest method testHandlePostSaveOrUpdate.
@Test
public void testHandlePostSaveOrUpdate() throws Exception {
try {
new NonStrictExpectations() {
{
}
};
} catch (Exception e) {
}
;
MockHttpRequestExecuter.setResponseCode(200);
MockHttpRequestExecuter.setResponseText("");
MockHttpRequestExecuter httpExecuter = new MockHttpRequestExecuter();
final ModelManager modelManager = new MockModelManager();
final GlobalSettings globalSettings = new GlobalSettings();
globalSettings.setServiceManagementAuthSalt(UUID.randomUUID().toString());
ClusterNode clusterNode = new ClusterNode();
clusterNode.setServiceWebUrlPrefix("http://www.openmeap.com/openmeap-services-web");
globalSettings.addClusterNode(clusterNode);
new NonStrictExpectations(globalSettings, modelManager) {
{
modelManager.getGlobalSettings();
result = globalSettings;
}
};
Application app = new Application();
app.setName("Happy Name");
app.setId(1L);
ModelServiceRefreshNotifier notifier = new ModelServiceRefreshNotifier();
notifier.setModelManager(modelManager);
notifier.setHttpRequestExecuter(httpExecuter);
notifier.notify(new ModelEntityModifyEvent(app), null);
String lastPostUrl = MockHttpRequestExecuter.getLastPostUrl();
Map<String, Object> lastPostData = MockHttpRequestExecuter.getLastPostData();
String uri = lastPostUrl;
String type = (String) lastPostData.get("type");
String auth = (String) lastPostData.get("auth");
String id = (String) lastPostData.get("id").toString();
Assert.assertTrue(uri.equals("http://www.openmeap.com/openmeap-services-web/service-management/"));
Assert.assertTrue(id.equals("1"));
Assert.assertTrue(type.equals("Application"));
Assert.assertTrue(AuthTokenProvider.validateAuthToken(globalSettings.getServiceManagementAuthSalt(), auth));
}
Aggregations