use of org.springframework.roo.model.CustomData in project spring-roo by spring-projects.
the class DefaultItdTypeDetailsTest method testMinimalInstance.
@Test
public void testMinimalInstance() {
// Set up
final boolean privilegedAspect = false;
final int modifier = 42;
final ClassOrInterfaceTypeDetails mockGovernor = mock(ClassOrInterfaceTypeDetails.class);
when(mockGovernor.getPhysicalTypeCategory()).thenReturn(PhysicalTypeCategory.CLASS);
final JavaPackage mockPackage = mock(JavaPackage.class);
when(mockPackage.getFullyQualifiedPackageName()).thenReturn("com.foo.bar");
final JavaType mockGovernorType = mock(JavaType.class);
when(mockGovernorType.getPackage()).thenReturn(mockPackage);
when(mockGovernor.getType()).thenReturn(mockGovernorType);
when(mockGovernorType.getSimpleTypeName()).thenReturn("Person");
when(mockGovernorType.getFullyQualifiedTypeName()).thenReturn("com.foo.bar.Person");
when(mockGovernorType.getDataType()).thenReturn(DataType.TYPE);
final CustomData mockCustomData = mock(CustomData.class);
final JavaType mockAspectType = mock(JavaType.class);
when(mockAspectType.getPackage()).thenReturn(mockPackage);
when(mockAspectType.isDefaultPackage()).thenReturn(false);
when(mockAspectType.getSimpleTypeName()).thenReturn("Person_Roo_Extra");
SortedMap<JavaType, Boolean> imports = new TreeMap<JavaType, Boolean>();
final JavaType mockImportType = mock(JavaType.class);
when(mockImportType.getSimpleTypeName()).thenReturn("Person");
when(mockImportType.getFullyQualifiedTypeName()).thenReturn("com.foo.bar.Person");
when(mockImportType.getDataType()).thenReturn(DataType.TYPE);
imports.put(mockImportType, false);
final String declaredByMetadataId = "MID:foo#bar";
// Invoke
final DefaultItdTypeDetails itd = new DefaultItdTypeDetails(mockCustomData, declaredByMetadataId, modifier, mockGovernor, mockAspectType, privilegedAspect, imports, null, null, null, null, null, null, null, null, null, null);
// Check
assertEquals(0, itd.getAnnotations().size());
assertEquals(0, itd.getDeclaredConstructors().size());
assertEquals(0, itd.getDeclaredFields().size());
assertEquals(0, itd.getDeclaredInitializers().size());
assertEquals(0, itd.getDeclaredInnerTypes().size());
assertEquals(0, itd.getDeclaredMethods().size());
assertEquals(0, itd.getExtendsTypes().size());
assertEquals(0, itd.getFieldAnnotations().size());
assertEquals(0, itd.getImplementsTypes().size());
assertEquals(0, itd.getInnerTypes().size());
assertEquals(0, itd.getDeclarePrecedence().size());
assertEquals(0, itd.getMethodAnnotations().size());
assertEquals(1, itd.getRegisteredImports().size());
assertEquals(mockAspectType, itd.getAspect());
assertEquals(mockCustomData, itd.getCustomData());
assertEquals(declaredByMetadataId, itd.getDeclaredByMetadataId());
assertEquals(modifier, itd.getModifier());
assertEquals(mockGovernorType, itd.getType());
assertEquals(DefaultItdTypeDetails.PHYSICAL_TYPE_CATEGORY, itd.getPhysicalTypeCategory());
assertEquals(privilegedAspect, itd.isPrivilegedAspect());
assertEquals(mockGovernor, itd.getGovernor());
assertFalse(itd.extendsType(mock(JavaType.class)));
assertOutput(MINIMAL_ITD, itd);
}
Aggregations