@Test public void shouldNotGetServiceIdWhenMissingMemberCode() throws Exception { when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_INSTANCE_IDENTIFIER))) .thenReturn(EXPECTED_XR_INSTANCE); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_MEMBER_CLASS))) .thenReturn("government"); when(mockRequest.getParameter(eq(WsdlRequestProcessor.PARAM_SERVICE_CODE))) .thenReturn("someServiceCode"); WsdlRequestProcessor processorToTest = new WsdlRequestProcessor(mockRequest, mockResponse); thrown.expect(CodedException.class); thrown.expect(faultCodeEquals(X_INVALID_REQUEST)); thrown.expectMessage(containsString("InvalidRequest: 'memberCode' must not be blank")); processorToTest.getServiceId(); }
ServiceId getServiceId() { String instance = request.getParameter(PARAM_INSTANCE_IDENTIFIER); if (isBlank(instance)) { throw new CodedException(X_INVALID_REQUEST, "Must specify instance identifier"); } String serviceCode = request.getParameter(PARAM_SERVICE_CODE); if (isBlank(serviceCode)) { throw new CodedException(X_INVALID_REQUEST, "Must specify service code"); } String memberClass = request.getParameter(PARAM_MEMBER_CLASS); String memberCode = request.getParameter(PARAM_MEMBER_CODE); String subsystemCode = request.getParameter(PARAM_SUBSYSTEM_CODE); String version = request.getParameter(PARAM_VERSION); try { if (isBlank(memberClass) && isBlank(memberCode)) { return CentralServiceId.create(instance, serviceCode); } else { return ServiceId.create(instance, memberClass, memberCode, subsystemCode, serviceCode, version); } } catch (Exception e) { throw new CodedException(X_INVALID_REQUEST, e.getMessage()); } }
WsdlRequestProcessor { ServiceId getServiceId() { String instance = request.getParameter(PARAM_INSTANCE_IDENTIFIER); if (isBlank(instance)) { throw new CodedException(X_INVALID_REQUEST, "Must specify instance identifier"); } String serviceCode = request.getParameter(PARAM_SERVICE_CODE); if (isBlank(serviceCode)) { throw new CodedException(X_INVALID_REQUEST, "Must specify service code"); } String memberClass = request.getParameter(PARAM_MEMBER_CLASS); String memberCode = request.getParameter(PARAM_MEMBER_CODE); String subsystemCode = request.getParameter(PARAM_SUBSYSTEM_CODE); String version = request.getParameter(PARAM_VERSION); try { if (isBlank(memberClass) && isBlank(memberCode)) { return CentralServiceId.create(instance, serviceCode); } else { return ServiceId.create(instance, memberClass, memberCode, subsystemCode, serviceCode, version); } } catch (Exception e) { throw new CodedException(X_INVALID_REQUEST, e.getMessage()); } } }
WsdlRequestProcessor { ServiceId getServiceId() { String instance = request.getParameter(PARAM_INSTANCE_IDENTIFIER); if (isBlank(instance)) { throw new CodedException(X_INVALID_REQUEST, "Must specify instance identifier"); } String serviceCode = request.getParameter(PARAM_SERVICE_CODE); if (isBlank(serviceCode)) { throw new CodedException(X_INVALID_REQUEST, "Must specify service code"); } String memberClass = request.getParameter(PARAM_MEMBER_CLASS); String memberCode = request.getParameter(PARAM_MEMBER_CODE); String subsystemCode = request.getParameter(PARAM_SUBSYSTEM_CODE); String version = request.getParameter(PARAM_VERSION); try { if (isBlank(memberClass) && isBlank(memberCode)) { return CentralServiceId.create(instance, serviceCode); } else { return ServiceId.create(instance, memberClass, memberCode, subsystemCode, serviceCode, version); } } catch (Exception e) { throw new CodedException(X_INVALID_REQUEST, e.getMessage()); } }  }
WsdlRequestProcessor { ServiceId getServiceId() { String instance = request.getParameter(PARAM_INSTANCE_IDENTIFIER); if (isBlank(instance)) { throw new CodedException(X_INVALID_REQUEST, "Must specify instance identifier"); } String serviceCode = request.getParameter(PARAM_SERVICE_CODE); if (isBlank(serviceCode)) { throw new CodedException(X_INVALID_REQUEST, "Must specify service code"); } String memberClass = request.getParameter(PARAM_MEMBER_CLASS); String memberCode = request.getParameter(PARAM_MEMBER_CODE); String subsystemCode = request.getParameter(PARAM_SUBSYSTEM_CODE); String version = request.getParameter(PARAM_VERSION); try { if (isBlank(memberClass) && isBlank(memberCode)) { return CentralServiceId.create(instance, serviceCode); } else { return ServiceId.create(instance, memberClass, memberCode, subsystemCode, serviceCode, version); } } catch (Exception e) { throw new CodedException(X_INVALID_REQUEST, e.getMessage()); } }   }
WsdlRequestProcessor { ServiceId getServiceId() { String instance = request.getParameter(PARAM_INSTANCE_IDENTIFIER); if (isBlank(instance)) { throw new CodedException(X_INVALID_REQUEST, "Must specify instance identifier"); } String serviceCode = request.getParameter(PARAM_SERVICE_CODE); if (isBlank(serviceCode)) { throw new CodedException(X_INVALID_REQUEST, "Must specify service code"); } String memberClass = request.getParameter(PARAM_MEMBER_CLASS); String memberCode = request.getParameter(PARAM_MEMBER_CODE); String subsystemCode = request.getParameter(PARAM_SUBSYSTEM_CODE); String version = request.getParameter(PARAM_VERSION); try { if (isBlank(memberClass) && isBlank(memberCode)) { return CentralServiceId.create(instance, serviceCode); } else { return ServiceId.create(instance, memberClass, memberCode, subsystemCode, serviceCode, version); } } catch (Exception e) { throw new CodedException(X_INVALID_REQUEST, e.getMessage()); } }   static final String PARAM_INSTANCE_IDENTIFIER; static final String PARAM_MEMBER_CLASS; static final String PARAM_MEMBER_CODE; static final String PARAM_SERVICE_CODE; }