@Test
public void fromClass() {

    MutableAnnotationTypeDeclaration actual
        = MutableAnnotationTypeDeclaration.fromClass(MemoryRequirements.class, CopyOptions.INSTANCE);
    Collections.sort(actual.getDeclaredAnnotations(), (first, second) -> {
        @Nullable MutableQualifiedNamable firstDeclaration = first.getDeclaration();
        @Nullable MutableQualifiedNamable secondDeclaration = second.getDeclaration();
        assert firstDeclaration != null && secondDeclaration != null;
        @Nullable Name firstName = firstDeclaration.getQualifiedName();
        @Nullable Name secondName = secondDeclaration.getQualifiedName();
        assert firstName != null && secondName != null;
        return firstName.compareTo(secondName);
    });
    Collections.sort(actual.getElements(), (first, second) -> {
        @Nullable Name firstName = first.getSimpleName();
        @Nullable Name secondName = second.getSimpleName();
        assert firstName != null && secondName != null;
        return firstName.compareTo(secondName);
    });
    MutableAnnotationTypeDeclaration expected = new MutableAnnotationTypeDeclaration()
        .setSimpleName(MemoryRequirements.class.getSimpleName())
        .setDeclaredAnnotations(Arrays.asList(
            new MutableAnnotation()
                .setDeclaration(BarAnnotation.class.getCanonicalName()),
            new MutableAnnotation()
                .setDeclaration(FooAnnotation.class.getCanonicalName())
                .setEntries(Collections.singletonList(
                    new MutableAnnotationEntry()
                        .setKey("value")
                        .setValue(new byte[]{(byte) 2, (byte) 3})
                ))
        ))
        .setElements(Arrays.asList(
            new MutableAnnotationTypeElement()
                .setSimpleName("unit")
                .setReturnType(new MutableDeclaredType().setDeclaration(String.class.getName()))
                .setDefaultValue("MB"),
            new MutableAnnotationTypeElement()
                .setSimpleName("value")
                .setReturnType(new MutablePrimitiveType().setPrimitiveKind(BarePrimitiveType.Kind.INT))
                .setDefaultValue(1024)
        ));
    Assert.assertEquals(actual, expected);
}