Exemplo n.º 1
0
  @Test(expected = InvalidTypeException.class)
  public void ifNoAbleInstantiatorIsFoundWillThrowAnException() {
    final MultiInstantiator mutliInstantiator = new MultiInstantiator(theMockInstantiator);

    context.checking(
        new Expectations() {
          {
            allowing(mockSubInstantiator).isAbleToInstantiate(with(any(Target.class)));
            will(returnValue(false));
          }
        });

    mutliInstantiator.instantiate(Target.create(Object.class, ""), null);
  }
Exemplo n.º 2
0
  @Test
  public void multiInstantiatorWillUseAnAbleInstantiator() throws Exception {
    final MultiInstantiator multiInstantiator = new MultiInstantiator(theMockInstantiator);

    context.checking(
        new Expectations() {
          {
            allowing(mockSubInstantiator).isAbleToInstantiate(with(any(Target.class)));
            will(returnValue(true));

            one(mockSubInstantiator)
                .instantiate(with(any(Target.class)), (with(any(Parameters.class))));
          }
        });

    multiInstantiator.instantiate(Target.create(Object.class, ""), null);
  }