Tabnine Logo
IllegalArgumentException.getCause
Code IndexAdd Tabnine to your IDE (free)

How to use
getCause
method
in
java.lang.IllegalArgumentException

Best Java code snippets using java.lang.IllegalArgumentException.getCause (Showing top 20 results out of 990)

origin: org.mockito/mockito-core

@SuppressWarnings("unchecked")
@Override
public <T> Class<T> mockClass(final MockFeatures<T> params) {
  try {
    ClassLoader classLoader = params.mockedType.getClassLoader();
    return (Class<T>) typeCache.findOrInsert(classLoader,
        new MockitoMockKey(params.mockedType, params.interfaces, params.serializableMode, params.stripAnnotations),
        new Callable<Class<?>>() {
          @Override
          public Class<?> call() throws Exception {
            return bytecodeGenerator.mockClass(params);
          }
        }, BOOTSTRAP_LOCK);
  } catch (IllegalArgumentException exception) {
    Throwable cause = exception.getCause();
    if (cause instanceof RuntimeException) {
      throw (RuntimeException) cause;
    } else {
      throw exception;
    }
  }
}
origin: prestodb/presto

Throwable cause = e.getCause();
if (cause instanceof UnrecognizedPropertyException) {
  UnrecognizedPropertyException ex = (UnrecognizedPropertyException) cause;
origin: prestodb/presto

Throwable cause = e.getCause();
if (cause instanceof UnrecognizedPropertyException) {
  UnrecognizedPropertyException ex = (UnrecognizedPropertyException) cause;
origin: eclipse-vertx/vert.x

private void testInvalidValueToPOJO(String key) {
 try {
  new JsonObject().put(key, "1").mapTo(MyType2.class);
  fail();
 } catch (IllegalArgumentException e) {
  assertThat(e.getCause(), is(instanceOf(InvalidFormatException.class)));
  InvalidFormatException ife = (InvalidFormatException) e.getCause();
  assertEquals("1", ife.getValue());
 }
}
origin: apache/hbase

@Test
public void testParseOptsWrongThreads() {
 Queue<String> opts = new LinkedList<>();
 String cmdName = "sequentialWrite";
 opts.offer(cmdName);
 opts.offer("qq");
 try {
  PerformanceEvaluation.parseOpts(opts);
 } catch (IllegalArgumentException e) {
  System.out.println(e.getMessage());
  assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
  assertTrue(e.getCause() instanceof NumberFormatException);
 }
}
origin: eclipse-vertx/vert.x

@Test
public void testThatInvalidValuesAsDefaultValueAreReported() throws CLIException {
 try {
  cli.addArgument(new TypedArgument<Integer>()
    .setIndex(0).setArgName("1").setType(Integer.class).setDefaultValue("a"));
 } catch (IllegalArgumentException e) {
  assertThat(e.getCause()).isInstanceOf(InvalidValueException.class);
  InvalidValueException cause = (InvalidValueException) e.getCause();
  assertThat(cause.getArgument().getIndex()).isEqualTo(0);
  assertThat(cause.getArgument().getArgName()).isEqualTo("1");
  assertThat(cause.getValue()).isEqualTo("a");
 }
}
origin: apache/hbase

@Test
public void testParseOptsNoThreads() {
 Queue<String> opts = new LinkedList<>();
 String cmdName = "sequentialWrite";
 try {
  PerformanceEvaluation.parseOpts(opts);
 } catch (IllegalArgumentException e) {
  System.out.println(e.getMessage());
  assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
  assertTrue(e.getCause() instanceof NoSuchElementException);
 }
}
origin: voldemort/voldemort

public void testClassWithNoParseFrom() {
  try {
    new ProtoBufSerializer<Message>("java=" + MessageWithNoParseFrom.class.getName());
  } catch(IllegalArgumentException e) {
    assertEquals(NoSuchMethodException.class, e.getCause().getClass());
    return;
  }
  fail("IllegalArgumentException should have been thrown");
}
origin: hibernate/hibernate-orm

@Test
public void testIncorrectSyntax() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  try {
    s.createQuery( "update Human set Human.description = 'xyz' where Human.id = 1 and Human.description is null" );
    fail( "expected failure" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch( QueryException expected ) {
    // ignore : expected behavior
  }
  t.commit();
  s.close();
}
origin: voldemort/voldemort

public void testNonExistentClass() {
  try {
    new ProtoBufSerializer<Message>("java=com.foo.Bar");
  } catch(IllegalArgumentException e) {
    assertEquals(ClassNotFoundException.class, e.getCause().getClass());
    return;
  }
  fail("IllegalArgumentException should have been thrown");
}
origin: hibernate/hibernate-orm

@Test
public void testDeleteNonExistentEntity() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  try {
    s.createQuery( "delete NonExistentEntity" ).executeUpdate();
    fail( "no exception thrown" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch( QueryException ignore ) {
  }
  t.commit();
  s.close();
}
origin: hibernate/hibernate-orm

@Test
public void testUpdateNonExistentEntity() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  try {
    s.createQuery( "update NonExistentEntity e set e.someProp = ?" ).executeUpdate();
    fail( "no exception thrown" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch( QueryException e ) {
  }
  t.commit();
  s.close();
}
origin: hibernate/hibernate-orm

@Test
public void testTupleReturnFails() {
  Session s = openSession();
  Transaction txn = s.beginTransaction();
  try {
    s.createQuery( "select a, a.weight from Animal a inner join fetch a.offspring" ).scroll();
    fail( "scroll allowed with collection fetch and reurning tuples" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch( HibernateException e ) {
    // expected result...
  }
  txn.commit();
  s.close();
}
origin: hibernate/hibernate-orm

@Test
public void testSelectWithNamedParamProjection() {
  Session s = openSession();
  try {
    s.createQuery("select :someParameter, id from Car");
    fail("Should throw an unsupported exception");
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch(QueryException q) {
    // allright
  }
  finally {
    s.close();
  }
}
origin: hibernate/hibernate-orm

@Test
public void testFetchInSubqueryFails() {
  Session s = openSession();
  try {
    s.createQuery( "from Animal a where a.mother in (select m from Animal a1 inner join a1.mother as m join fetch m.mother)" ).list();
    fail( "fetch join allowed in subquery" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch( QueryException expected ) {
    // expected behavior
  }
  s.close();
}
origin: checkstyle/checkstyle

@Test
public void testIoExceptionWhenLoadingHeader() throws Exception {
  final HeaderCheck check = PowerMockito.spy(new HeaderCheck());
  PowerMockito.doThrow(new IOException("expected exception")).when(check, "loadHeader",
      any());
  try {
    check.setHeader("header");
    fail("Exception expected");
  }
  catch (IllegalArgumentException ex) {
    assertTrue("Invalid exception cause", ex.getCause() instanceof IOException);
    assertEquals("Invalid exception message", "unable to load header", ex.getMessage());
  }
}
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-11942" )
public void testOrderByExtraParenthesis() throws Exception {
  try {
    doInHibernate( this::sessionFactory, session -> {
      session.createQuery(
        "select a from Product a " +
        "where " +
        "coalesce(a.description, :description) = :description ) " +
        "order by a.description ", Product.class)
      .setParameter( "description", "desc" )
      .getResultList();
      fail("Should have thrown exception");
    } );
  }
  catch (IllegalArgumentException e) {
    final Throwable cause = e.getCause();
    assertThat( cause, instanceOf( QuerySyntaxException.class ) );
    assertTrue( cause.getMessage().contains( "expecting EOF, found ')'" ) );
  }
}
origin: hibernate/hibernate-orm

@Test
public void testWithClauseFailsWithFetch() {
  TestData data = new TestData();
  data.prepare();
  Session s = openSession();
  Transaction txn = s.beginTransaction();
  try {
    s.createQuery( "from Animal a inner join fetch a.offspring as o with o.bodyWeight = :someLimit" )
        .setDouble( "someLimit", 1 )
        .list();
    fail( "ad-hoc on clause allowed with fetched association" );
  }
  catch (IllegalArgumentException e) {
    assertTyping( QueryException.class, e.getCause() );
  }
  catch ( HibernateException e ) {
    // the expected response...
  }
  txn.commit();
  s.close();
  data.cleanup();
}
origin: hibernate/hibernate-orm

@Test
public void testUpdateOnImplicitJoinFails() {
  inTransaction(
      s -> {
        try {
          s.createQuery( "update Human set mother.name.initial = :initial" ).setString( "initial", "F" ).executeUpdate();
          fail( "update allowed across implicit join" );
        }
        catch (IllegalArgumentException e) {
          assertTyping( QueryException.class, e.getCause() );
        }
        catch( QueryException e ) {
        }
      }
  );
}
origin: hibernate/hibernate-orm

@Test
public void testMultipleBagFetchesFail() {
  try ( final SessionImplementor s = (SessionImplementor) openSession() ) {
    inTransaction(
        s,
        session-> {
          try {
            s.createQuery( "from Human h join fetch h.friends f join fetch f.friends fof" ).list();
            fail( "failure expected" );
          }
          catch (IllegalArgumentException e) {
            assertTyping( MultipleBagFetchException.class, e.getCause() );
          }
          catch( HibernateException e ) {
            assertTrue( "unexpected failure reason : " + e, e.getMessage().indexOf( "multiple bags" ) > 0 );
          }
        }
    );
  }
}
java.langIllegalArgumentExceptiongetCause

Popular methods of IllegalArgumentException

  • <init>
    Constructs a new exception with the specified cause and a detail message of (cause==null ? null : c
  • getMessage
  • printStackTrace
  • initCause
  • toString
  • getLocalizedMessage
  • getStackTrace
  • setStackTrace
  • addSuppressed
  • fillInStackTrace
  • getSuppressed
  • getSuppressed

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Reference (javax.naming)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now