List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:com.wirelust.sonar.plugins.bitbucket.PullRequestFacadeTest.java
@Test public void shouldHandlePullRequestApprovalFailure() throws Exception { setDefaultConfig();/* w w w . j a v a 2 s . c om*/ // post global comment when(bitbucketV2Client.postPullRequestApproval(any(String.class), any(String.class), any(Long.class))) .thenReturn(responseFailure); PullRequestFacade pullRequestFacade = new PullRequestFacade(configuration, apiClientFactory); pullRequestFacade.init(123, temporaryFolder.getRoot()); try { pullRequestFacade.approvePullRequest(); Assert.fail(); } catch (IllegalStateException e) { assertEquals("Unable to update pull request approval status. expected:200, got:500", e.getMessage()); } }
From source file:org.finra.herd.service.helper.notification.UserNamespaceAuthorizationChangeMessageBuilderTest.java
@Test public void testBuildUserNamespaceAuthorizationChangeMessagesJsonPayloadNoMessageType() throws Exception { // Create a user namespace authorization key. UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID, BDEF_NAMESPACE);/*from w w w. ja v a 2s . c o m*/ // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity .setKey(ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, USER_NAMESPACE_AUTHORIZATION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { userNamespaceAuthorizationChangeMessageBuilder.buildNotificationMessages( new UserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey)); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:net.di2e.ecdr.commons.query.rest.CDRQueryImpl.java
protected Filter getContextualFilter(FilterBuilder filterBuilder, String keywords, boolean caseSensitive, boolean isStrcitMode, boolean fuzzy) throws UnsupportedQueryException { Filter filter = null;/* w w w . ja v a 2 s . c o m*/ if (keywords != null) { KeywordTextParser keywordParser = Parboiled.createParser(KeywordTextParser.class); ParseRunner<ASTNode> runner = isStrictMode ? new ReportingParseRunner<ASTNode>(keywordParser.inputPhrase()) : new RecoveringParseRunner<ASTNode>(keywordParser.inputPhrase()); ParsingResult<ASTNode> parsingResult = runner.run(keywords); if (!parsingResult.hasErrors()) { try { filter = getFilterFromASTNode(filterBuilder, parsingResult.resultValue, caseSensitive, fuzzy); } catch (IllegalStateException e) { throw new UnsupportedQueryException("searchTerms parameter [" + keywords + "] was invalid and resulted in the error: " + e.getMessage()); } } else { throw new UnsupportedQueryException( "searchTerms parameter [" + keywords + "] was invalid and resulted in the error: " + parsingResult.parseErrors.get(0).getErrorMessage()); } humanReadableQueryBuilder.append(" " + SearchConstants.KEYWORD_PARAMETER + "=[" + keywords + "] " + SearchConstants.CASESENSITIVE_PARAMETER + "=[" + caseSensitive + "] " + SearchConstants.FUZZY_PARAMETER + "=[" + fuzzy + "]"); } return filter; }
From source file:com.github.rinde.rinsim.core.SimulatorTest.java
/** * Tests that not using a dependency is detected. *//*from w w w . ja v a2 s. c o m*/ @Test public void testNopBuilder() { final Simulator.Builder b = Simulator.builder().addModel(new NopBuilder()).addModel(new A()) .addModel(new B()); boolean fail = false; try { b.build(); } catch (final IllegalStateException e) { assertThat(e.getMessage()).containsMatch("dependencies MUST be requested"); fail = true; } assertThat(fail).isTrue(); }
From source file:org.finra.herd.service.helper.notification.UserNamespaceAuthorizationChangeMessageBuilderTest.java
@Test public void testBuildUserNamespaceAuthorizationChangeMessagesJsonPayloadNoMessageDestination() throws Exception { // Create a user namespace authorization key. UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID, BDEF_NAMESPACE);/*from ww w . ja v a2 s.co m*/ // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity .setKey(ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION, USER_NAMESPACE_AUTHORIZATION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { userNamespaceAuthorizationChangeMessageBuilder.buildNotificationMessages( new UserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey)); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.apache.maven.doxia.linkcheck.DefaultLinkCheck.java
/** * Create the XML document from the currently available details. * * @throws IOException if any/*from w w w .ja v a2s. c o m*/ */ private void createDocument(LinkcheckModel model) throws IOException { if (this.reportOutput == null) { return; } File dir = this.reportOutput.getParentFile(); if (dir != null) { dir.mkdirs(); } Writer writer = null; LinkcheckModelXpp3Writer xpp3Writer = new LinkcheckModelXpp3Writer(); try { writer = WriterFactory.newXmlWriter(this.reportOutput); xpp3Writer.write(writer, model); } catch (IllegalStateException e) { IOException ioe = new IOException( e.getMessage() + " Maybe try to specify an other encoding instead of '" + encoding + "'."); ioe.initCause(e); throw ioe; } finally { IOUtil.close(writer); } dir = null; }
From source file:org.kuali.rice.krad.datadictionary.uif.UifDictionaryIndex.java
/** * Gets a view instance from the pool or factory but does not replace the view, meant for view readonly * access (not running the lifecycle but just checking configuration) * * @param viewId the unique id for the view * @return View instance with the given id */// w ww . j a v a 2 s . c om public View getImmutableViewById(String viewId) { ProcessLogger.trace("view:" + viewId); View cachedView = viewCache.get(viewId); if (cachedView != null) { ProcessLogger.trace("view:cache-hit"); } else { ProcessLogger.trace("view:cache-miss"); if (LOG.isDebugEnabled()) { LOG.debug("View " + viewId + " not in cache - creating and storing to cache"); } final String beanName = viewBeanEntriesById.get(viewId); if (StringUtils.isBlank(beanName)) { throw new DataDictionaryException("Unable to find View with id: " + viewId); } ProcessLogger.trace("view:init:" + viewId); View view = ddBeans.getBean(beanName, View.class); ProcessLogger.trace("view:getBean"); if (UifConstants.ViewStatus.CREATED.equals(view.getViewStatus())) { try { ViewLifecycle.preProcess(view); ProcessLogger.trace("view:preProcess"); } catch (IllegalStateException ex) { if (LOG.isDebugEnabled()) { LOG.debug("preProcess not run due to an IllegalStateException. " + "Exception message: " + ex.getMessage()); } } } boolean inDevMode = ConfigContext.getCurrentContextConfig() .getBooleanProperty(KRADConstants.ConfigParameters.KRAD_DEV_MODE); if (!inDevMode) { synchronized (viewCache) { viewCache.put(viewId, view); } ProcessLogger.trace("view:cached"); } else if (LOG.isDebugEnabled()) { LOG.debug("DEV MODE - View " + viewId + " will not be cached"); ProcessLogger.trace("view:dev-mode"); } cachedView = view; } ProcessLogger.trace("view-immutable:" + viewId); return cachedView; }
From source file:org.apache.cxf.fediz.service.idp.protocols.TrustedIdpSAMLProtocolHandler.java
@Override public SecurityToken mapSignInResponse(RequestContext context, Idp idp, TrustedIdp trustedIdp) { try {//from w w w . ja v a2 s . co m String encodedSAMLResponse = (String) WebUtils.getAttributeFromFlowScope(context, SSOConstants.SAML_RESPONSE); // Read the response + convert to an OpenSAML Response Object org.opensaml.saml2.core.Response samlResponse = readSAMLResponse(encodedSAMLResponse, trustedIdp); Crypto crypto = getCrypto(trustedIdp.getCertificate()); validateSamlResponseProtocol(samlResponse, crypto, trustedIdp); // Validate the Response SSOValidatorResponse validatorResponse = validateSamlSSOResponse(samlResponse, idp, trustedIdp, context); // Create new Security token with new id. // Parameters for freshness computation are copied from original IDP_TOKEN String id = IDGenerator.generateID("_"); SecurityToken idpToken = new SecurityToken(id, validatorResponse.getCreated(), validatorResponse.getSessionNotOnOrAfter()); idpToken.setToken(validatorResponse.getAssertionElement()); String whr = (String) WebUtils.getAttributeFromFlowScope(context, FederationConstants.PARAM_HOME_REALM); LOG.info("[IDP_TOKEN={}] created from [RP_TOKEN={}] issued by home realm [{}]", id, validatorResponse.getResponseId(), whr); LOG.debug("Created date={}", validatorResponse.getCreated()); LOG.debug("Expired date={}", validatorResponse.getSessionNotOnOrAfter()); if (LOG.isDebugEnabled()) { LOG.debug("Validated: " + System.getProperty("line.separator") + validatorResponse.getAssertion()); } return idpToken; } catch (IllegalStateException ex) { throw ex; } catch (Exception ex) { LOG.warn("Unexpected exception occured", ex); throw new IllegalStateException("Unexpected exception occured: " + ex.getMessage()); } }
From source file:com.vmware.identity.samlservice.impl.LogoutStateValidator.java
/** * Validate LogoutRequest//ww w .j a v a 2 s . c o m * * @param vr * @param accessor * @param request * @return */ private ValidationResult validateLogoutRequest(ValidationResult vr, IdmAccessor accessor, LogoutRequest request) { Validate.notNull(request.getIssuer()); // Validate single logout service first, if that is valid, we can send // SAML replies try { @SuppressWarnings("unused") String acsUrl = accessor.getSloForRelyingParty(request.getIssuer().getValue(), OasisNames.HTTP_REDIRECT); } catch (IllegalStateException e) { // set validation result to 400 log.debug("Caught illegal state exception while Validating " + e.toString() + ", returning 400"); vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null); } // Validate ID if (vr == null && request.getID() == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Request ID is missing"); } // Validate version if (vr == null) { SAMLVersion version = request.getVersion(); if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too high vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH); log.debug("Validation FAILED - Version is too high"); } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too low vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW); log.debug("Validation FAILED - Version is too low"); } } // Validate IssueInstant if (vr == null) { DateTime dtPlus = request.getIssueInstant(); DateTime dtMinus = request.getIssueInstant(); DateTime instant = new DateTime(); long clockTolerance = accessor.getClockTolerance(); if (dtPlus == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant is missing"); } else { dtPlus = dtPlus.plus(clockTolerance); dtMinus = dtMinus.minus(clockTolerance); // dtPlus must be after now and dtMinus must be before now // in order to satisfy clock tolerance if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant outside of clock tolerance"); log.debug("clockTolerance {}", clockTolerance); log.debug("now {}", instant); log.debug("dtPlus {}", dtPlus.toString()); log.debug("dtMinus {}", dtMinus.toString()); } } } // Destination URL skipped, this is already done by OpenSAML when // parsing // Validate NotOnOrAfter if (vr == null) { DateTime notOnOrAfter = request.getNotOnOrAfter(); if (notOnOrAfter != null) { DateTime instant = new DateTime(); if (!instant.isBefore(notOnOrAfter)) { vr = new ValidationResult(OasisNames.REQUESTER, OasisNames.REQUEST_DENIED); log.debug("Validation FAILED - NotOnOrAfter condition violated"); log.debug("now {}", instant); log.debug("notOnOrAfter {}", notOnOrAfter.toString()); } } } // validate NameID if (vr == null) { NameID nameID = request.getNameID(); if (nameID == null || nameID.getFormat() == null || nameID.getValue() == null) { log.debug("Validation FAILED for NameID: node, format or value missing"); vr = new ValidationResult(OasisNames.REQUESTER); } } // validate session index if (vr == null) { List<SessionIndex> sessionList = request.getSessionIndexes(); if (sessionList == null || sessionList.size() == 0) { log.debug("Validation FAILED for session indices: at least one session index is required"); vr = new ValidationResult(OasisNames.REQUESTER); } } // validation done if (vr == null) { vr = new ValidationResult(); // success } return vr; }
From source file:org.fornax.toolsupport.sculptor.maven.plugin.GeneratorMojo.java
@SuppressWarnings("unchecked") private List<File> toFileList(FileSet fileSet) { File directory = new File(fileSet.getDirectory()); String includes = toCommaSeparatedString(fileSet.getIncludes()); String excludes = toCommaSeparatedString(fileSet.getExcludes()); try {// w w w.j a va 2 s .c om return FileUtils.getFiles(directory, includes, excludes); } catch (IllegalStateException e) { getLog().warn(e.getMessage() + ". Ignoring fileset."); } catch (IOException e) { getLog().warn(e); } return Collections.emptyList(); }