private Metadata newAllAuthorizationsMetadata(String schemaCode) {
   String code = schemaCode + "_allauthorizations";
   Metadata metadata = mock(Metadata.class, code);
   when(metadata.getLocalCode()).thenReturn("allauthorizations");
   when(metadata.getCode()).thenReturn(code);
   when(metadata.getType()).thenReturn(MetadataValueType.STRING);
   return metadata;
 }
 private Metadata newPathMetadata(String schemaCode) {
   String code = schemaCode + "_path";
   Metadata metadata = mock(Metadata.class, code);
   when(metadata.getLocalCode()).thenReturn("path");
   when(metadata.getCode()).thenReturn(code);
   when(metadata.getType()).thenReturn(MetadataValueType.STRING);
   return metadata;
 }
  private Metadata configureMetadataWithHierarchyDependency(
      Metadata metadata, MetadataSchemaTypes types, String code) {

    when(metadata.getCode()).thenReturn(code);
    when(metadata.getLocalCode()).thenReturn(code.split("_")[2]);
    MetadataValueCalculator metadataValueCalculator = mock(MetadataValueCalculator.class);
    List dependencies = Arrays.asList(SpecialDependencies.HIERARCHY);
    when(metadataValueCalculator.getDependencies()).thenReturn(dependencies);
    when(metadata.getDataEntry()).thenReturn(new CalculatedDataEntry(metadataValueCalculator));
    return metadata;
  }
  private Metadata givenReferenceToSchemaType(
      Metadata metadata, MetadataSchemaTypes types, String code, boolean childOf, String type) {
    when(metadata.getCode()).thenReturn(code);
    when(metadata.getLocalCode()).thenReturn(code.split("_")[2]);
    when(metadata.getType()).thenReturn(MetadataValueType.REFERENCE);

    AllowedReferences allowedReferences = new AllowedReferences(type, null);
    when(metadata.getAllowedReferences()).thenReturn(allowedReferences);
    when(types.getMetadata(code)).thenReturn(metadata);

    return metadata;
  }