private MetadataSchemaType configureMockedSchemaTypeWithTaxonomyRelations( MetadataSchemaType type, MetadataSchemaTypes types, String code, Metadata... taxonomyRelations) { when(type.getCode()).thenReturn(code); List<Metadata> metadatas = Arrays.asList(taxonomyRelations); when(type.getAllReferencesToTaxonomySchemas(taxonomies)).thenReturn(metadatas); when(types.getSchemaType(code)).thenReturn(type); return type; }
@Before public void setUp() throws Exception { taxonomies = new ArrayList<>(); zeSchemaPath = newPathMetadata("zeSchema_default"); type1Path = newPathMetadata("type1_default"); type2Path = newPathMetadata("type2_default"); type3Path = newPathMetadata("type3_default"); type4Path = newPathMetadata("type4_default"); zeSchemaAllAuthorizations = newAllAuthorizationsMetadata("zeSchema_default"); type1AllAuthorizations = newAllAuthorizationsMetadata("type1_default"); type2AllAuthorizations = newAllAuthorizationsMetadata("type2_default"); type3AllAuthorizations = newAllAuthorizationsMetadata("type3_default"); type4AllAuthorizations = newAllAuthorizationsMetadata("type4_default"); givenReferenceToSchemaType( type1RelationToType1, types, "type1_default_relationToType1", childOfRelation, "type1"); givenReferenceToSchemaType( type2RelationToType1, types, "type2_default_relationToType1", childOfRelation, "type1"); givenReferenceToSchemaType( type2RelationToType2, types, "type2_default_relationToType2", childOfRelation, "type2"); givenReferenceToSchemaType( type3RelationToType2, types, "type3_default_relationToType2", childOfRelation, "type2"); givenReferenceToSchemaType( type3RelationToType2NotUsedInTaxonomies, types, "type3_default_relationToType2NotUsed", normalRelation, "type2"); givenReferenceToSchemas( type4CustomRelationToType2Custom, types, "type4_custom_relationToType2Custom", childOfRelation, "type2_custom"); givenReferenceToSchemaType( zeSchemaTaxos, types, "zeSchema_default_zeSchemaTaxos", normalRelation, "type3"); givenReferenceToSchemas( anotherSchemaTaxos, types, "anotherSchema_default_anotherSchemaTaxos", normalRelation, "type2_custom"); taxonomies.add( Taxonomy.createPublic( "anotherTaxo", "anotherTaxo", "zeCollection", new ArrayList<String>())); taxonomies.add( Taxonomy.createPublic( "zeTaxo", "zeTaxo", "zeCollection", Arrays.asList("type1", "type2", "type3"))); configureMetadataWithHierarchyDependency( automaticMetaInType1UsingTaxos, types, "type1_default_inheritedauthorizations"); configureMetadataWithHierarchyDependency( automaticMetaInType2UsingTaxos, types, "type2_default_inheritedauthorizations"); configureMetadataWithHierarchyDependency( automaticMetaInType3UsingTaxos, types, "type3_default_inheritedauthorizations"); configureMetadataWithHierarchyDependency( automaticMetaInType4UsingTaxos, types, "type4_custom_inheritedauthorizations"); configureMetadataWithHierarchyDependency( automaticMetaInZeSchemaUsingTaxos, types, "zeSchema_default_inheritedauthorizations"); configureMetadataWithHierarchyDependency( automaticMetaInAnotherSchemaUsingTaxos, types, "anotherSchema_default_inheritedauthorizations"); givenReferenceToSchemaType( type1ReferenceToType1NotBusedByTaxos, types, "type1_default_notUsed", normalRelation, "type1"); givenReferenceToSchemas( type2ReferenceToType1NotBusedByTaxos, types, "type2_default_notUsed", normalRelation, "type1_default"); givenReferenceToSchemas( type3ReferenceToType2NotBusedByTaxos, types, "type3_default_notUsed", normalRelation, "type2"); givenReferenceToSchemas( type4ReferenceToType3NotBusedByTaxos, types, "type4_default_notUsed", normalRelation, "type3_default"); givenReferenceToSchemas( zeSchemaReferenceToType3NotBusedByTaxos, types, "zeSchema_default_notUsed", normalRelation, "type3_default"); givenReferenceToSchemaType( zeSchemaReferenceToZeSchema, types, "zeSchema_default_parent", childOfRelation, "zeSchema"); givenReferenceToSchemas( anotherSchemaReferenceToType3NotBusedByTaxos, types, "anotherSchema_default_notUsed", normalRelation, "type3_default"); givenReferenceToSchemas( anotherSchemaReferenceToZeSchema, types, "anotherSchema_default_parent", childOfRelation, "zeSchema_custom"); configureMockedSchemaWithTaxonomyRelations( type1Schema, types, "type1_default", type1RelationToType1); configureMockedSchemaWithTaxonomyRelations( type2Schema, types, "type2_default", type2RelationToType1, type2RelationToType2); configureMockedSchemaWithTaxonomyRelations( type2CustomSchema, types, "type2_custom", type2RelationToType1, type2RelationToType2); configureMockedSchemaWithTaxonomyRelations( type3Schema, types, "type3_default", type3RelationToType2); configureMockedSchemaWithTaxonomyRelations( type4Schema, types, "type4_custom", type4CustomRelationToType2Custom); configureMockedSchemaWithTaxonomyRelations(zeSchema, types, "zeSchema_default"); configureMockedSchemaWithTaxonomyRelations(anotherSchema, types, "anotherSchema_default"); configureMockedSchemaTypeWithTaxonomyRelations(type1, types, "type1", type1RelationToType1); configureMockedSchemaTypeWithTaxonomyRelations( type2, types, "type2", type2RelationToType1, type2RelationToType2); configureMockedSchemaTypeWithTaxonomyRelations(type3, types, "type3", type3RelationToType2); configureMockedSchemaTypeWithTaxonomyRelations( type4, types, "type4", type4CustomRelationToType2Custom); configureMockedSchemaTypeWithTaxonomyRelations(zeType, types, "zeSchema"); configureMockedSchemaTypeWithTaxonomyRelations(anotherType, types, "anotherSchema"); when(type1.getAllReferencesToTaxonomySchemas(taxonomies)).thenReturn(new ArrayList<Metadata>()); when(type2.getAllReferencesToTaxonomySchemas(taxonomies)).thenReturn(new ArrayList<Metadata>()); when(type3.getAllReferencesToTaxonomySchemas(taxonomies)).thenReturn(new ArrayList<Metadata>()); when(type4.getAllReferencesToTaxonomySchemas(taxonomies)).thenReturn(new ArrayList<Metadata>()); when(zeType.getAllReferencesToTaxonomySchemas(taxonomies)) .thenReturn(Arrays.asList(zeSchemaTaxos)); when(anotherType.getAllReferencesToTaxonomySchemas(taxonomies)) .thenReturn(Arrays.asList(anotherSchemaTaxos)); when(type1.getAllParentReferences()).thenReturn(Arrays.asList(type1RelationToType1)); when(type2.getAllParentReferences()) .thenReturn(Arrays.asList(type2RelationToType1, type2RelationToType2)); when(type3.getAllParentReferences()).thenReturn(Arrays.asList(type3RelationToType2)); when(type4.getAllParentReferences()) .thenReturn(Arrays.asList(type4CustomRelationToType2Custom)); when(zeType.getAllParentReferences()).thenReturn(Arrays.asList(zeSchemaReferenceToZeSchema)); when(anotherType.getAllParentReferences()) .thenReturn(Arrays.asList(anotherSchemaReferenceToZeSchema)); calculator = new ModificationImpactCalculator(types, taxonomies, searchServices); }
public static ConditionTemplate schemaTypeIs(MetadataSchemaType type) { return schemaTypeIs(type.getCode()); }