Example usage for java.lang AssertionError AssertionError

List of usage examples for java.lang AssertionError AssertionError

Introduction

In this page you can find the example usage for java.lang AssertionError AssertionError.

Prototype

public AssertionError() 

Source Link

Document

Constructs an AssertionError with no detail message.

Usage

From source file:com.microsoft.services.msa.OAuthSuccessfulResponse.java

public static OAuthSuccessfulResponse createFromFragment(Map<String, String> fragmentParameters)
        throws LiveAuthException {
    String accessToken = fragmentParameters.get(OAuth.ACCESS_TOKEN);
    String tokenTypeString = fragmentParameters.get(OAuth.TOKEN_TYPE);

    // must have accessToken and tokenTypeString to be a valid OAuthSuccessfulResponse
    if (accessToken == null)
        throw new AssertionError();
    if (tokenTypeString == null)
        throw new AssertionError();

    OAuth.TokenType tokenType;//from   w ww  . jav a 2 s . com
    try {
        tokenType = OAuth.TokenType.valueOf(tokenTypeString.toUpperCase());
    } catch (IllegalArgumentException e) {
        throw new LiveAuthException(ErrorMessages.SERVER_ERROR, e);
    }

    Builder builder = new Builder(accessToken, tokenType);

    String authenticationToken = fragmentParameters.get(OAuth.AUTHENTICATION_TOKEN);
    if (authenticationToken != null) {
        builder.authenticationToken(authenticationToken);
    }

    String expiresInString = fragmentParameters.get(OAuth.EXPIRES_IN);
    if (expiresInString != null) {
        final int expiresIn;
        try {
            expiresIn = Integer.parseInt(expiresInString);
        } catch (final NumberFormatException e) {
            throw new LiveAuthException(ErrorMessages.SERVER_ERROR, e);
        }

        builder.expiresIn(expiresIn);
    }

    String scope = fragmentParameters.get(OAuth.SCOPE);
    if (scope != null) {
        builder.scope(scope);
    }

    return builder.build();
}

From source file:com.xtructure.xutil.valid.strategy.UTestArgumentValidationStrategy.java

public void processFailureBehavesAsExpected() {
    Condition predicate = isNotNull();
    Object object = null;/*from  w  w w  . j av  a  2  s. c  o  m*/
    String msg = RandomStringUtils.randomAlphanumeric(10);
    ArgumentValidationStrategy<Object> vs = new ArgumentValidationStrategy<Object>(predicate);
    try {
        vs.validate(object);
    } catch (IllegalArgumentException e) {
        if (!String.format("%s (%s): %s", ArgumentValidationStrategy.DEFAULT_MSG, object, predicate)
                .equals(e.getMessage())) {
            throw new AssertionError();
        }
    }
    try {
        vs.validate(object, msg);
    } catch (IllegalArgumentException e) {
        if (!String.format("%s (%s): %s", msg, object, predicate).equals(e.getMessage())) {
            throw new AssertionError();
        }
    }
}

From source file:edu.oregonstate.eecs.mcplan.domains.cosmic.CosmicTransitionSimulator.java

@Override
public ActionNode<CosmicState, CosmicAction> sampleTransition(final RandomGenerator rng, final CosmicState s,
        final CosmicAction a) {
    final double ar = reward(s, a);
    final CosmicState sprime;
    switch (params.getCosmicVersion()) {
    case take_action:
        sprime = params.cosmic.take_action(s, a, params.delta_t);
        break;//from w  w  w.  jav  a 2s.  co m
    case take_action_iter:
        sprime = params.cosmic.take_action_iter(s, a, params.delta_t);
        break;
    case take_action2:
        sprime = params.cosmic.take_action2(context, s, a, params.delta_t);
        break;
    default:
        throw new AssertionError();
    }

    final double sr = reward(sprime);
    //      System.out.println( "\tr = " + r );
    final ActionNode<CosmicState, CosmicAction> tr = new ActionNode<>(a, ar);
    tr.addSuccessor(new StateNode<CosmicState, CosmicAction>(sprime, sr));
    Log.info("a: {}", a);
    Log.info("ar: {}", ar);
    Log.info("sprime: {}", sprime);
    Log.info("sr: {}", sr);

    fireTransitionSample(tr);

    return tr;
}

From source file:com.roche.sequencing.bioinformatics.common.utils.FileUtil.java

private FileUtil() {
    throw new AssertionError();
}

From source file:de.unentscheidbar.csv2.ParserBenchmark.java

@Benchmark
public void readFromMemory() {

    try {/*w  w w . j a  va 2s.c o  m*/
        Reader r = new InputStreamReader(new ByteArrayInputStream(csv), StandardCharsets.UTF_16BE);
        Collection<?> rows = impl.getRows(r);
        if (rows.size() == 0)
            throw new AssertionError();
        for (Object row : rows) {
            if (row == notARow)
                throw new AssertionError();
        }
    } catch (Exception e) {
        throw new AssertionError(e);
    }
}

From source file:com.alexshabanov.springrestapi.support.ProfileController.java

@ExceptionHandler(UnsupportedOperationException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/*www. j  a va2 s. c  o  m*/
public ErrorDesc handleUnsupportedOperationException() {
    throw new AssertionError();
}

From source file:forge.game.GameActionUtil.java

private GameActionUtil() {
    throw new AssertionError();
}

From source file:com.android.development.ExceptionBrowser.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Cursor cursor = getContentResolver().query(Checkin.Crashes.CONTENT_URI,
            new String[] { Checkin.Crashes._ID, Checkin.Crashes.DATA }, null, null, null);

    if (cursor != null) {
        startManagingCursor(cursor);//from  ww w.  j  a va2s  .  com

        setListAdapter(new CursorAdapter(this, cursor, true) {
            public View newView(Context context, Cursor c, ViewGroup v) {
                return new CrashListItem(context);
            }

            public void bindView(View view, Context c, Cursor cursor) {
                CrashListItem item = (CrashListItem) view;
                try {
                    String data = cursor.getString(1);
                    CrashData crash = new CrashData(new DataInputStream(
                            new ByteArrayInputStream(Base64.decodeBase64(data.getBytes()))));

                    ThrowableData exc = crash.getThrowableData();
                    item.setText(exc.getType() + ": " + exc.getMessage());
                    item.setCrashData(crash);
                } catch (IOException e) {
                    item.setText("Invalid crash: " + e);
                    Log.e(TAG, "Invalid crash", e);
                }
            }
        });
    } else {
        // No database, no exceptions, empty list.
        setListAdapter(new BaseAdapter() {
            public int getCount() {
                return 0;
            }

            public Object getItem(int position) {
                throw new AssertionError();
            }

            public long getItemId(int position) {
                throw new AssertionError();
            }

            public View getView(int position, View convertView, ViewGroup parent) {
                throw new AssertionError();
            }
        });
    }
}

From source file:org.operamasks.faces.render.graph.CompositeChartRenderer.java

protected JFreeChart createChart(UIChart comp) {
    throw new AssertionError();
}

From source file:eu.itesla_project.modules.rules.PrintSecurityRuleTool.java

@Override
public void run(CommandLine line) throws Exception {
    OfflineConfig config = OfflineConfig.load();
    String rulesDbName = line.hasOption("rules-db-name") ? line.getOptionValue("rules-db-name")
            : OfflineConfig.DEFAULT_RULES_DB_NAME;
    RulesDbClient rulesDb = config.getRulesDbClientFactoryClass().newInstance().create(rulesDbName);
    String workflowId = line.getOptionValue("workflow");
    RuleAttributeSet attributeSet = RuleAttributeSet.valueOf(line.getOptionValue("attribute-set"));
    String contingency = line.getOptionValue("contingency");
    SecurityIndexType indexType = SecurityIndexType.valueOf(line.getOptionValue("index-type"));
    ExpressionPrintFormat format = ExpressionPrintFormat.ASCII_FLAT;
    if (line.hasOption("format")) {
        format = ExpressionPrintFormat.valueOf(line.getOptionValue("format"));
    }//  ww  w .  j a v  a 2  s.co  m
    double purityThreshold = PrintSecurityRuleCommand.DEFAULT_PURITY_THRESHOLD;
    if (line.hasOption("purity-threshold")) {
        purityThreshold = Double.parseDouble(line.getOptionValue("purity-threshold"));
    }
    List<SecurityRule> rules = rulesDb.getRules(workflowId, attributeSet, contingency, indexType);
    if (rules.isEmpty()) {
        throw new RuntimeException("Security rule not found");
    }
    SecurityRule rule = rules.get(0);
    SecurityRuleExpression securityRuleExpression = rule.toExpression(purityThreshold);
    if (securityRuleExpression.getStatus() == SecurityRuleStatus.ALWAYS_SECURE
            || securityRuleExpression.getStatus() == SecurityRuleStatus.ALWAYS_UNSECURE) {
        System.out.println(securityRuleExpression.getStatus());
    }
    ExpressionNode condition = securityRuleExpression.getCondition();
    String str;
    switch (format) {
    case ASCII_FLAT:
        str = ExpressionFlatPrinter.toString(condition);
        break;
    case ASCII_TREE:
        str = ExpressionTreePrinter.toString(condition);
        break;
    case GRAPHVIZ_TREE:
        str = ExpressionGraphvizPrinter.toString(condition);
        break;
    default:
        throw new AssertionError();
    }
    System.out.println(str);
}