@Test public void getRemoteConfigurationFixesPartialBaseURL() throws ComponentLookupException, ClientProtocolException, IOException { when(this.configObject.getStringValue("url")).thenReturn("localhost:8080"); when(this.response.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK")); when(this.response.getEntity()) .thenReturn(new ByteArrayEntity("{\"response_protocol_version\":\"1.2\"}".getBytes())); Assert.assertNotNull( this.mocker.getComponentUnderTest().getRemoteConfiguration("RemoteServer1", "name", "pass", "token")); Mockito.verify(this.client).execute(Matchers.any(HttpPost.class)); HttpPost request = this.post.getValue(); Assert.assertEquals("http: }
@Override public PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName, String password, String userToken) { PushServerConfigurationResponse serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, ShareProtocol.CURRENT_PUSH_PROTOCOL_VERSION); if (serverResponse == null) { return null; } String serverProtocolVersion = serverResponse.getServerProtocolVersion(); if (serverProtocolVersion == null || ShareProtocol.OLD_INCOMPATIBLE_VERSIONS.contains(serverProtocolVersion)) { return new UnsupportedOldServerProtocolResponse(); } if (serverResponse.isServerDoesNotAcceptClientProtocolVersion() && ShareProtocol.COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS.contains(serverProtocolVersion)) { serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, serverProtocolVersion); } this.protocolVersionsCache.put(remoteServerIdentifier, serverProtocolVersion); return serverResponse; }
DefaultPushPatientData implements PushPatientData { @Override public PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName, String password, String userToken) { PushServerConfigurationResponse serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, ShareProtocol.CURRENT_PUSH_PROTOCOL_VERSION); if (serverResponse == null) { return null; } String serverProtocolVersion = serverResponse.getServerProtocolVersion(); if (serverProtocolVersion == null || ShareProtocol.OLD_INCOMPATIBLE_VERSIONS.contains(serverProtocolVersion)) { return new UnsupportedOldServerProtocolResponse(); } if (serverResponse.isServerDoesNotAcceptClientProtocolVersion() && ShareProtocol.COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS.contains(serverProtocolVersion)) { serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, serverProtocolVersion); } this.protocolVersionsCache.put(remoteServerIdentifier, serverProtocolVersion); return serverResponse; } }
DefaultPushPatientData implements PushPatientData { @Override public PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName, String password, String userToken) { PushServerConfigurationResponse serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, ShareProtocol.CURRENT_PUSH_PROTOCOL_VERSION); if (serverResponse == null) { return null; } String serverProtocolVersion = serverResponse.getServerProtocolVersion(); if (serverProtocolVersion == null || ShareProtocol.OLD_INCOMPATIBLE_VERSIONS.contains(serverProtocolVersion)) { return new UnsupportedOldServerProtocolResponse(); } if (serverResponse.isServerDoesNotAcceptClientProtocolVersion() && ShareProtocol.COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS.contains(serverProtocolVersion)) { serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, serverProtocolVersion); } this.protocolVersionsCache.put(remoteServerIdentifier, serverProtocolVersion); return serverResponse; }  }
DefaultPushPatientData implements PushPatientData { @Override public PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName, String password, String userToken) { PushServerConfigurationResponse serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, ShareProtocol.CURRENT_PUSH_PROTOCOL_VERSION); if (serverResponse == null) { return null; } String serverProtocolVersion = serverResponse.getServerProtocolVersion(); if (serverProtocolVersion == null || ShareProtocol.OLD_INCOMPATIBLE_VERSIONS.contains(serverProtocolVersion)) { return new UnsupportedOldServerProtocolResponse(); } if (serverResponse.isServerDoesNotAcceptClientProtocolVersion() && ShareProtocol.COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS.contains(serverProtocolVersion)) { serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, serverProtocolVersion); } this.protocolVersionsCache.put(remoteServerIdentifier, serverProtocolVersion); return serverResponse; }  @Override PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName,
        String password, String userToken); @Override PushServerSendPatientResponse sendPatient(Patient patient, Set<String> exportFields,
        JSONObject patientState,
        String groupName, String remoteGUID, String remoteServerIdentifier, String userName, String password,
        String userToken); @Override PushServerGetPatientIDResponse getPatientURL(String remoteServerIdentifier, String remoteGUID,
        String userName, String password, String userToken); }
DefaultPushPatientData implements PushPatientData { @Override public PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName, String password, String userToken) { PushServerConfigurationResponse serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, ShareProtocol.CURRENT_PUSH_PROTOCOL_VERSION); if (serverResponse == null) { return null; } String serverProtocolVersion = serverResponse.getServerProtocolVersion(); if (serverProtocolVersion == null || ShareProtocol.OLD_INCOMPATIBLE_VERSIONS.contains(serverProtocolVersion)) { return new UnsupportedOldServerProtocolResponse(); } if (serverResponse.isServerDoesNotAcceptClientProtocolVersion() && ShareProtocol.COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS.contains(serverProtocolVersion)) { serverResponse = this.sendRemoteConfigurationRequest( remoteServerIdentifier, userName, password, userToken, serverProtocolVersion); } this.protocolVersionsCache.put(remoteServerIdentifier, serverProtocolVersion); return serverResponse; }  @Override PushServerConfigurationResponse getRemoteConfiguration(String remoteServerIdentifier, String userName,
        String password, String userToken); @Override PushServerSendPatientResponse sendPatient(Patient patient, Set<String> exportFields,
        JSONObject patientState,
        String groupName, String remoteGUID, String remoteServerIdentifier, String userName, String password,
        String userToken); @Override PushServerGetPatientIDResponse getPatientURL(String remoteServerIdentifier, String remoteGUID,
        String userName, String password, String userToken); static final String PUSH_SERVER_CONFIG_ID_PROPERTY_NAME; static final String PUSH_SERVER_CONFIG_URL_PROPERTY_NAME; static final String PUSH_SERVER_CONFIG_REGISTRATION_URL_PROPERTY_NAME; static final String PUSH_SERVER_CONFIG_DESC_PROPERTY_NAME; }