Search in sources :

Example 81 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project wicket by apache.

the class XmlLicenseHeaderHandler method checkLicenseHeader.

@Override
public boolean checkLicenseHeader(final File file) {
    Revision revision = null;
    try {
        String header = extractLicenseHeader(file, 0, 17);
        if (header.startsWith("<?xml")) {
            header = header.substring(header.indexOf(LINE_ENDING) + LINE_ENDING.length());
        } else {
            // Then only take the first 16 lines
            String[] headers = header.split(LINE_ENDING);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; (i < 16) && (i < headers.length); i++) {
                if (sb.length() > 0) {
                    sb.append(LINE_ENDING);
                }
                sb.append(headers[i]);
            }
            header = sb.toString();
        }
        revision = Diff.diff(getLicenseHeader().split(LINE_ENDING), header.split(LINE_ENDING));
    } catch (Exception e) {
        throw new AssertionFailedError(e.getMessage());
    }
    return revision.size() == 0;
}
Also used : Revision(org.apache.wicket.util.diff.Revision) AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 82 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project dpc-app by CMSgov.

the class TokenResourceTest method testTokenSigning.

@Test
void testTokenSigning() throws IOException, URISyntaxException {
    final IParser parser = ctx.newJsonParser();
    final IGenericClient attrClient = APITestHelpers.buildAttributionClient(ctx);
    // Create a new org and make sure it has no providers
    final String m2 = FHIRHelpers.registerOrganization(attrClient, parser, OTHER_ORG_ID, "1112111111", getAdminURL());
    // Create a new JWT
    final APIAuthHelpers.AuthResponse authResponse = APIAuthHelpers.jwtAuthFlow(this.getBaseURL(), fullyAuthedToken, PUBLIC_KEY_ID, PRIVATE_KEY);
    assertAll(() -> assertNotEquals("", authResponse.accessToken, "Should have token"), () -> assertEquals(300, authResponse.expiresIn, "Should be valid for 300 seconds"), () -> assertEquals("system/*.*", authResponse.scope, "Should have correct scope"), () -> assertEquals("bearer", authResponse.tokenType, "Should be a macaroon"));
    // Try to authenticate using the private key for org 1 and the token for org 2, should throw an exception, but in the auth handler
    final AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> APIAuthHelpers.jwtAuthFlow(this.getBaseURL(), m2, PUBLIC_KEY_ID, PRIVATE_KEY));
    error.getMessage();
}
Also used : IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) APIAuthHelpers(gov.cms.dpc.testing.APIAuthHelpers) AssertionFailedError(org.opentest4j.AssertionFailedError) IParser(ca.uhn.fhir.parser.IParser) AbstractSecureApplicationTest(gov.cms.dpc.api.AbstractSecureApplicationTest) Test(org.junit.jupiter.api.Test)

Example 83 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project josm by openstreetmap.

the class AlignInCircleActionTest method testSelectionEvaluation.

/**
 * Various cases of selections in file
 * @throws Exception if an error occurs
 */
@Test
void testSelectionEvaluation() throws Exception {
    DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleCases.osm")), null);
    for (int i = 0; i < 80; i++) {
        final String selVal = Integer.toString(i);
        Set<OsmPrimitive> sel = ds.allPrimitives().stream().filter(p -> p.hasTag("sel", selVal)).collect(Collectors.toSet());
        if (sel.isEmpty())
            continue;
        ds.setSelected(sel);
        boolean selValid = sel.stream().noneMatch(p -> p.hasKey("invalid-selection"));
        try {
            AlignInCircleAction.buildCommand(ds);
            assertTrue(selValid, "sel=" + selVal + " is not valid?");
        } catch (InvalidSelection e) {
            assertFalse(selValid, "sel=" + selVal + " is not invalid?");
        } catch (Exception e) {
            throw new AssertionFailedError("test failed: sel=" + selVal, e);
        }
    }
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) OsmPrimitive(org.openstreetmap.josm.data.osm.OsmPrimitive) Files(java.nio.file.Files) Way(org.openstreetmap.josm.data.osm.Way) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Set(java.util.Set) InvalidSelection(org.openstreetmap.josm.actions.AlignInCircleAction.InvalidSelection) DataSet(org.openstreetmap.josm.data.osm.DataSet) Collectors(java.util.stream.Collectors) Node(org.openstreetmap.josm.data.osm.Node) JOSMTestRules(org.openstreetmap.josm.testutils.JOSMTestRules) Test(org.junit.jupiter.api.Test) OsmReader(org.openstreetmap.josm.io.OsmReader) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TestUtils(org.openstreetmap.josm.TestUtils) Paths(java.nio.file.Paths) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) AssertionFailedError(org.opentest4j.AssertionFailedError) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Command(org.openstreetmap.josm.command.Command) DataSet(org.openstreetmap.josm.data.osm.DataSet) OsmPrimitive(org.openstreetmap.josm.data.osm.OsmPrimitive) AssertionFailedError(org.opentest4j.AssertionFailedError) InvalidSelection(org.openstreetmap.josm.actions.AlignInCircleAction.InvalidSelection) Test(org.junit.jupiter.api.Test)

Example 84 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project nebula-jdbc by nebula-contrib.

the class NebulaResultSetTest method checkReturnedDateTimeValueInNotUTCTimeZone.

@Test
public void checkReturnedDateTimeValueInNotUTCTimeZone() throws SQLException {
    log.warn("make sure you have set the timezone in server into CST+8.");
    statement.executeUpdate("INSERT VERTEX testNode (theString, theInt, theDouble, theTrueBool, theFalseBool, theDate, theTime, theDatetime) " + "VALUES \"testNode_9\":(\"Summer\", 19, 93.65, true, false, date(\"1950-01-26\"), time(\"17:23:30.153\"), datetime(\"1950-07-15T01:06:20.456\"));");
    NebulaResultSet resultSet = (NebulaResultSet) statement.executeQuery("MATCH (v:testNode) RETURN id(v) AS id ,v.testNode.theDate as theDate, v.testNode.theTime as theTime, v.testNode.theDatetime as theDatetime ORDER BY id ASC");
    resultSet.absolute(7);
    try {
        assertEquals(Date.valueOf("1950-01-26"), resultSet.getDate("theDate"));
        assertEquals(Time.valueOf("09:23:30"), resultSet.getTime("theTime"));
        DateTimeWrapper theDatetime = resultSet.getDateTime("theDatetime");
        assertEquals(1950, theDatetime.getYear());
        assertEquals(7, theDatetime.getMonth());
        assertEquals(14, theDatetime.getDay());
        assertEquals(17, theDatetime.getHour());
        assertEquals(6, theDatetime.getMinute());
        assertEquals(20, theDatetime.getSecond());
    } catch (AssertionFailedError e) {
        log.error("error occurs here, maybe time zone in server is not CST+8");
        statement.executeUpdate("DELETE VERTEX \"testNode_9\"");
    }
}
Also used : DateTimeWrapper(com.vesoft.nebula.client.graph.data.DateTimeWrapper) NebulaResultSet(com.vesoft.nebula.jdbc.impl.NebulaResultSet) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 85 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project invesdwin-util by invesdwin.

the class ExpressionParserTest method testIfParametersOperator.

@Test
public void testIfParametersOperator() {
    for (final Op op : Op.values()) {
        if (op == Op.NOT || op == Op.CROSSES_ABOVE || op == Op.CROSSES_BELOW) {
            continue;
        }
        try {
            String opStr = op.toString();
            if (Characters.isAsciiAlpha(opStr.charAt(0))) {
                opStr = " " + opStr + " ";
            }
            final IExpression parsed = new ExpressionParser("if(random" + opStr + "random,1,0)") {

                @Override
                protected IParsedExpression simplify(final IParsedExpression expression) {
                    return expression;
                }
            }.parse();
            Assertions.checkEquals("if((random " + op + " random), 1, 0)", parsed.toString());
            final IExpression parsedAgain = new ExpressionParser(parsed.toString()) {

                @Override
                protected IParsedExpression simplify(final IParsedExpression expression) {
                    return expression;
                }
            }.parse();
            Assertions.checkEquals(parsed.toString(), parsedAgain.toString());
        } catch (final Throwable t) {
            if (t instanceof AssertionFailedError) {
                throw t;
            } else {
                throw new RuntimeException("At: " + op, t);
            }
        }
    }
}
Also used : IParsedExpression(de.invesdwin.util.math.expression.eval.IParsedExpression) Op(de.invesdwin.util.math.expression.eval.operation.Op) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)153 Test (org.junit.jupiter.api.Test)72 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 Collectors (java.util.stream.Collectors)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 ExecutionException (java.util.concurrent.ExecutionException)3 Assertions (org.junit.jupiter.api.Assertions)3