@Test
 public void shouldHaveNoSpecifiedButUnrealizedDependencies() {
   List<String> unrealized = new ArrayList<>();
   packageDependencies
       .keySet()
       .stream()
       .map(Package::getPackage)
       .forEach(
           sourcePackage ->
               dependenciesOf(sourcePackage)
                   .stream()
                   .filter(
                       dependency ->
                           !packageDependencies.get(sourcePackage.getName()).contains(dependency))
                   .forEach(target -> unrealized.add(sourcePackage + " -> " + target)));
   if (!unrealized.isEmpty()) fail("unrealized dependencies:\n" + String.join("\n", unrealized));
 }
 @Test
 public void shouldHaveOnlyDefinedDependencies() {
   List<String> unexpected = new ArrayList<>();
   packageDependencies
       .keySet()
       .stream()
       .map(Package::getPackage)
       .forEach(
           sourcePackage -> {
             List<String> allowed = dependenciesOf(sourcePackage);
             String source = sourcePackage.getName();
             packageDependencies
                 .get(source)
                 .stream()
                 .filter(target -> !source.equals(target))
                 .filter(target -> !allowed.contains(target))
                 .filter(target -> !isAlwaysAllowed(target))
                 .forEach(target -> unexpected.add(source + " -> " + target));
           });
   if (!unexpected.isEmpty()) fail("unexpected dependencies:\n" + String.join("\n", unexpected));
 }
Example #3
0
 @Mock
 public int computeX(Invocation inv, int a, int b) {
   inputValues.add(a);
   inputValues.add(b);
   int x = inv.proceed();
   outputValues.add(x);
   return x;
 }
 private List<String> dependenciesOf(Package source) {
   List<String> result = new ArrayList<>();
   if (source.isAnnotationPresent(DependsUpon.class))
     for (Class<?> target : source.getAnnotation(DependsUpon.class).packagesOf())
       result.add(target.getPackage().getName());
   return result;
 }
  @Test
  @Ignore
  public void showAllNonShippedOrders() throws Exception {
    orders.add(new Order("a", "b", "c"));
    orders.add(new Order("d", "e", "f"));

    when(request.getMethod()).thenReturn("GET");
    when(request.getRequestURI()).thenReturn("/orders");

    ordersController.service();

    verify(ordersView).show(orders);
  }
Example #6
0
    @Mock
    public int computeX(Invocation inv, int a, int b) {
      Integer x;

      try {
        x = inv.proceed();
        return x;
      } finally {
        // Statements to be executed on exit would be here.
        //noinspection UnusedAssignment
        x = a + b;
        values.add(x);
      }
    }
  @Test
  @Ignore
  public void theControllerWillShipAnOrder() throws Exception {
    Order order = new Order("5555", "_", "_");
    orders.add(order);

    when(request.getMethod()).thenReturn("POST");
    when(request.getRequestURI()).thenReturn("/orders/shipped");
    when(request.getParameter("order_code")).thenReturn("5555");

    ordersController.service();

    assertEquals("controller should set shipped", true, order.isShipped());
    verify(ordersView).refresh();
  }
Example #8
0
 @Mock
 public int computeX(Invocation inv, int a, int b) {
   values.add(a + b);
   return inv.proceed();
 }