org.junit.matchers.JUnitMatchers Java Examples

The following examples show how to use org.junit.matchers.JUnitMatchers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MappingUnitTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
@Test
public void pickupTargetStepsFor_OutputIsNotDefined() throws Exception {
  StepMeta singleMeta = new StepMeta( "single", null );
  StepMeta copiedMeta = new StepMeta( "copied", null );
  Mockito.when( mockHelper.transMeta.findNextSteps( mockHelper.stepMeta ) ).thenReturn( Arrays.asList( singleMeta, copiedMeta ) );

  StepInterface single = Mockito.mock( StepInterface.class );
  Mockito.when( mockHelper.trans.findStepInterfaces( "single" ) ).thenReturn( Collections.singletonList( single ) );

  StepInterface copy1 = Mockito.mock( StepInterface.class );
  StepInterface copy2 = Mockito.mock( StepInterface.class );
  Mockito.when( mockHelper.trans.findStepInterfaces( "copied" ) ).thenReturn( Arrays.asList( copy1, copy2 ) );

  MappingIODefinition definition = new MappingIODefinition( null, null );
  StepInterface[] targetSteps = mapping.pickupTargetStepsFor( definition );

  assertThat( Arrays.asList( targetSteps ), JUnitMatchers.hasItems( is( single ), is( copy1 ), is( copy2 ) ) );
}
 
Example #2
Source File: PrivateDatabasesTestTemplate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void doTest_OnePrivate_TwoShared() throws Exception {
  T meta = createMeta();
  DatabaseMeta privateMeta = createDatabase( "privateMeta" );
  meta.addDatabase( privateMeta );

  String xml = toXml( meta );

  DatabaseMeta meta1 = createDatabase( "meta1" );
  meta1.setShared( true );
  DatabaseMeta meta2 = createDatabase( "meta2" );
  meta2.setShared( true );

  SharedObjects fakeSharedObjects = createFakeSharedObjects( meta1, meta2 );

  T loaded = fromXml( xml, fakeSharedObjects );

  List<String> loadedDbs = Arrays.asList( loaded.getDatabaseNames() );
  assertEquals( 3, loadedDbs.size() );
  assertThat( loadedDbs, JUnitMatchers.hasItems( "meta1", "meta2", "privateMeta" ) );

  Set<String> privateDatabases = loaded.getPrivateDatabases();
  assertNotNull( privateDatabases );
  assertEquals( 1, privateDatabases.size() );
  assertTrue( privateDatabases.contains( "privateMeta" ) );
}
 
Example #3
Source File: TestDriftRuleEL.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testDriftNamesIncompatibleTypes() throws Exception {
  ELVars vars = new ELVariables();

  Record record = new RecordImpl("creator", "id", null, null);
  record.set(Field.create(1));

  RecordEL.setRecordInContext(vars, record);

  vars.addContextVariable(DataRuleEvaluator.PIPELINE_CONTEXT, new HashMap<>());
  vars.addContextVariable(DataRuleEvaluator.RULE_ID_CONTEXT, "ID");

  ELEval elEval = new ELEvaluator("", ConcreteELDefinitionExtractor.get(), DriftRuleEL.class, AlertInfoEL.class);

  Assert.assertFalse(elEval.eval(vars, "${drift:names('/', true)}", Boolean.TYPE));
  Assert.assertThat(elEval.eval(vars, "${alert:info()}", String.class), JUnitMatchers.containsString("Field / have unsupported type of INTEGER."));
}
 
Example #4
Source File: TestDriftRuleEL.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testDriftOrderIncompatibleTypes() throws Exception {
  ELVars vars = new ELVariables();

  Record record = new RecordImpl("creator", "id", null, null);
  record.set(Field.create(1));

  RecordEL.setRecordInContext(vars, record);

  vars.addContextVariable(DataRuleEvaluator.PIPELINE_CONTEXT, new HashMap<>());
  vars.addContextVariable(DataRuleEvaluator.RULE_ID_CONTEXT, "ID");

  ELEval elEval = new ELEvaluator("", ConcreteELDefinitionExtractor.get(), DriftRuleEL.class, AlertInfoEL.class);

  Assert.assertFalse(elEval.eval(vars, "${drift:order('/', true)}", Boolean.TYPE));
  Assert.assertThat(elEval.eval(vars, "${alert:info()}", String.class), JUnitMatchers.containsString("Field / have unsupported type of INTEGER."));
}
 
Example #5
Source File: BatchlogEndpointFilterTest.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSelect2hostsFromNonLocalRacks() throws UnknownHostException
{
    Multimap<String, InetAddress> endpoints = ImmutableMultimap.<String, InetAddress> builder()
            .put(LOCAL, InetAddress.getByName("0"))
            .put(LOCAL, InetAddress.getByName("00"))
            .put("1", InetAddress.getByName("1"))
            .put("1", InetAddress.getByName("11"))
            .put("2", InetAddress.getByName("2"))
            .put("2", InetAddress.getByName("22"))
            .build();
    Collection<InetAddress> result = new TestEndpointFilter(LOCAL, endpoints).filter();
    assertThat(result.size(), is(2));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("11")));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("22")));
}
 
Example #6
Source File: RouteRuleTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr, "");
        Assert.fail();
    }catch(ParseException expected){
        assertThat(expected.getMessage(), JUnitMatchers.containsString("Illegal route rule without then express"));
    }
}
 
Example #7
Source File: MappingUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "unchecked" )
@Test
public void pickupTargetStepsFor_OutputIsDefined() throws Exception {
  StepInterface copy1 = Mockito.mock( StepInterface.class );
  StepInterface copy2 = Mockito.mock( StepInterface.class );
  Mockito.when( mockHelper.trans.findStepInterfaces( "copied" ) ).thenReturn( Arrays.asList( copy1, copy2 ) );

  MappingIODefinition definition = new MappingIODefinition( null, "copied" );
  StepInterface[] targetSteps = mapping.pickupTargetStepsFor( definition );

  assertThat( Arrays.asList( targetSteps ), JUnitMatchers.hasItems( is( copy1 ), is( copy2 ) ) );
}
 
Example #8
Source File: BatchlogEndpointFilterTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSelectTwoFirstHostsFromSingleOtherRack() throws UnknownHostException
{
    Multimap<String, InetAddress> endpoints = ImmutableMultimap.<String, InetAddress> builder()
            .put(LOCAL, InetAddress.getByName("0"))
            .put(LOCAL, InetAddress.getByName("00"))
            .put("1", InetAddress.getByName("1"))
            .put("1", InetAddress.getByName("11"))
            .put("1", InetAddress.getByName("111"))
            .build();
    Collection<InetAddress> result = new TestEndpointFilter(LOCAL, endpoints).filter();
    assertThat(result.size(), is(2));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("1")));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("11")));
}
 
Example #9
Source File: BatchlogEndpointFilterTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnAsIsIfNoEnoughEndpoints() throws UnknownHostException
{
    Multimap<String, InetAddress> endpoints = ImmutableMultimap.<String, InetAddress> builder()
            .put(LOCAL, InetAddress.getByName("0"))
            .build();
    Collection<InetAddress> result = new TestEndpointFilter(LOCAL, endpoints).filter();
    assertThat(result.size(), is(1));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("0")));
}
 
Example #10
Source File: BatchlogEndpointFilterTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSelectHostFromLocal() throws UnknownHostException
{
    Multimap<String, InetAddress> endpoints = ImmutableMultimap.<String, InetAddress> builder()
            .put(LOCAL, InetAddress.getByName("0"))
            .put(LOCAL, InetAddress.getByName("00"))
            .put("1", InetAddress.getByName("1"))
            .build();
    Collection<InetAddress> result = new TestEndpointFilter(LOCAL, endpoints).filter();
    assertThat(result.size(), is(2));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("1")));
    assertThat(result, JUnitMatchers.hasItem(InetAddress.getByName("0")));
}
 
Example #11
Source File: ListContainerSortablePropertiesTest.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Test
public void testSortableProperties() {
    ListContainer<Person> listContainer = new ListContainer<>(Service.getListOfPersons(100));
    listContainer.setContainerPropertyIds("id", "firstName", "lastName", "age", "groups[0].name", "generated");

    Object[] expectedSortableProperties = new Object[] {"id", "firstName", "lastName", "age", "groups[0].name"};
    Collection<Object> actualSortableProperties = (Collection<Object>) listContainer.getSortableContainerPropertyIds();
    Assert.assertThat(actualSortableProperties, JUnitMatchers.hasItems(expectedSortableProperties));
}
 
Example #12
Source File: FingerprintMain.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
  final FpTestClass1 fp1 = new FpTestClass1();
  final FpTestClass2 fp2 = new FpTestClass2();
  fp2.instanceMethod(new JUnitMatchers());
  fp2.schedule(new Runnable() {
    @Override
    public void run() {
    }
  });
}
 
Example #13
Source File: RouteRuleTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr, "");
        Assert.fail();
    }catch(ParseException expected){
        assertThat(expected.getMessage(), JUnitMatchers.containsString("Illegal route rule without then express"));
    }
}
 
Example #14
Source File: RouteRuleTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr, "");
        Assert.fail();
    }catch(ParseException expected){
        assertThat(expected.getMessage(), JUnitMatchers.containsString("Illegal route rule without then express"));
    }
}
 
Example #15
Source File: RouteRuleTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr, "");
        Assert.fail();
    }catch(ParseException expected){
        assertThat(expected.getMessage(), JUnitMatchers.containsString("Illegal route rule without then express"));
    }
}
 
Example #16
Source File: RouteRuleTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr, "");
        Assert.fail();
    }catch(ParseException expected){
        assertThat(expected.getMessage(), JUnitMatchers.containsString("Illegal route rule without then express"));
    }
}
 
Example #17
Source File: FpTestClass2.java    From java-specialagent with Apache License 2.0 4 votes vote down vote up
@Factory
@SuppressWarnings("unused")
 public Object instanceMethod(final JUnitMatchers type) throws javax.el.PropertyNotFoundException {
  return new org.junit.runner.notification.RunNotifier();
}