You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: permission_templates.rb
    path of file: ./repos/hyrax/spec/factories
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
FactoryBot.define do
  factory :permission_template, class: Hyrax::Per
    
    def self.find_or_create_admin_set_valkyrie(source_id)
      if source_id.present?
        begin
          Hyrax.query_service.find_by(id: source_id)
        rescue Valkyrie::Persistence::ObjectNotFoundError
          # Creating an Administrative set with a pre-determined id will not work for all adapters
          # so we're letting the adapter assign the id
          FactoryBot.valkyrie_create(:hyrax_admin_set)
        end