#!/usr/bin/perl -w

use strict;
use lib "path_to_bugzilla";

use Bugzilla;
use Bugzilla::Bug;
use Bugzilla::Product;
use Bugzilla::User;
use Bugzilla::Version;

my $TESTID = 132; #330
my $TESTPROD='xml';
my $TESTPRODID = 14; #xml

my $bug = new Bugzilla::Bug($TESTID);
print "integration_get_product_name: ".$bug->product()."\n";

my $user = $bug->assigned_to();
if( $user) {
  print "integration_get_bug_owner: ".$user->login()."\n";
}

$user = $bug->reporter();
if( $user) {
  print "integration_get_bug_reporter_email: ".$user->email()."\n";
}

my (@cc) = $bug->cc();
if( @cc) {
  print "integration_get_bug_monitors_email_list: ".@cc."\n";
  foreach my $c ( @cc) {
    foreach my $c1 ( @$c) {
      print "  $c1\n";
    }
  }
}

print "integration_get_bug_status: ".$bug->bug_status()."\n";
print "integration_get_bug_subject: ".$bug->short_desc()."\n";

#integration_add_tag
#my $product = new Bugzilla::Product($TESTPRODID);
my $product = new Bugzilla::Product({ name => $TESTPROD });

print "pid:".$product->id."\n";
print "pname:".$product->name."\n";
print "pversions...\n";
my $versions = $product->versions();
if( $versions) {
  foreach ( @$versions) {
    print "  ".$_->name."\n";
  }
}
my $v = Bugzilla::Version::create( "test_version_on_product", $product);

#integration_delete_tag
$v->remove_from_db();


print "OK.\n";
1;
