#!/usr/bin/env ruby

require 'rubygems'
require 'bundler'
Bundler.setup(:default)
require 'nakamura/test'
require 'nakamura/search'
require 'nakamura/contacts'
require 'test/unit.rb'
include SlingContacts

class TC_Kern289Test < Test::Unit::TestCase
  include SlingTest

  def test_connection_details
    m = uniqueness()
    u1 = create_user("testuser#{m}")
    u2 = create_user("otheruser#{m}")
    
    home1 = u1.home_path_for(@s)
    
    cm = ContactManager.new(@s)
    @s.switch_user(u1)
    cm.invite_contact(u2.name, "follower")
    #@s.debug = true
    wait_for_indexer()
    contacts = cm.get_pending()
    #@s.debug = false
    assert_not_nil(contacts)
    assert_not_nil(contacts["results"]," No Contacts found")
    assert_not_nil(contacts["results"][0], " No Contacts found ")
    types = contacts["results"][0]["details"]["sakai:types"]
    assert_not_nil(types, "Expected type to be stored")
    types = [*types]
    assert_equal("follower", types.first, "Expected type to be 'follower'")
  end

end


