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 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 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;
  }
 private void addPropertiesForMetadatas(
     Record record, Set<String> orgfilter, String typeId, PropertiesImpl result) {
   for (Metadata metadata :
       modelLayerFactory
           .getMetadataSchemasManager()
           .getSchemaTypes(record.getCollection())
           .getSchema(record.getSchemaCode())
           .getMetadatas()) {
     Object value = record.get(metadata);
     String propertyCode = metadata.getCode();
     if (value != null) {
       if (!metadata.isMultivalue()) {
         addPropertyForSingleValueMetadata(
             orgfilter, typeId, result, metadata, value, propertyCode);
       } else {
         addPropertyForMultiValueMetadata(
             orgfilter, typeId, result, metadata, value, propertyCode);
       }
     }
   }
 }