Siebel-Integration-Com

 view release on metacpan or  search on metacpan

t/test.t  view on Meta::CPAN

	ok($SiebelApp->SetProfileAttr($appData{profAttrName}, $appData{profAttrVal}), "SetProfileAttr $appData{profAttrName}");
	is($SiebelApp->GetProfileAttr($appData{profAttrName}), $appData{profAttrVal}, "GetProfileAttr $appData{profAttrName}");
	ok($SiebelApp->CurrencyCode(), "CurrencyCode");
	ok($SiebelApp->LoginId(), "LoginId");
	is($SiebelApp->LoginName(), $inputs{user}, "LoginName");
	ok($SiebelApp->PositionId(), "PositionId");
	ok($SiebelApp->PositionName(), "PositionName");
	ok($SiebelApp->SetSharedGlobal($appData{globalAttrName}, $appData{globalAttrVal}), "SetSharedGlobal $appData{globalAttrName}");
	is($SiebelApp->GetSharedGlobal($appData{globalAttrName}), $appData{globalAttrVal}, "GetSharedGlobal $appData{profAttrName}");
	ok($SiebelApp->InvokeMethod("GetDataSource"), "InvokeMethod GetDataSource");
	ok($SiebelApp->EnableExceptions(1), "EnableExceptions On");
	ok($SiebelApp->EnableExceptions(0), "EnableExceptions Off");
	
	SKIP: {
        skip('Test data not set for Set Position methods', 4) if ((!defined $testData{SetPositionId}) || (!defined $testData{SetPositionIdName}));
		my $orig_pos_id = $SiebelApp->PositionId();
		my $orig_pos_name = $SiebelApp->PositionName();
		ok($SiebelApp->SetPositionId($testData{SetPositionId}),"SetPositionId $testData{SetPositionId}");
		is($SiebelApp->PositionName(), $testData{SetPositionIdName}, "PositionName $testData{SetPositionIdName}");
		ok($SiebelApp->SetPositionName($orig_pos_name),"Reset SetPositionName $orig_pos_name");
		is($SiebelApp->PositionId(), $orig_pos_id, "PositionId $orig_pos_id");
	}
    #TODO: {
        #local $TODO = 'Multiple Arguments to InvokeMethod is not working....';
		#need to work out best method to call to test this.....
		#ok($SiebelApp->InvokeMethod("AMethodName", 'Arg1','Arg2'), "InvokeMethod Multi args");
    #}
}


sub TestAPPTrace{
	my $SiebelApp = shift;
	ok($SiebelApp->TraceOn('c:/temp/trace_$p_$t.log','Allocation','All'), 'TraceOn c:/temp/trace_$p_$t.log');
	ok($SiebelApp->Trace('Trace on line: ' . __LINE__), 'Trace: Trace on line: ' . __LINE__);
	ok($SiebelApp->TraceOff(), 'TraceOff');
}

########################################################################################################################################################
###############################					END APP TESTS							################################################################
########################################################################################################################################################

########################################################################################################################################################
###############################					START PROPSET TESTS						################################################################
########################################################################################################################################################

sub TestPropSet{
	my $SiebelApp = shift;
	
	my %props = (
		Type => 'A Test Value For Type',
		Value => 'ABCD',
		Prop1 => 'This is Test Prop 1 Value set',
		Prop2 => '2',
		Prop3 => '3',
		Prop4 => '4',
		Prop5 => '5',
		Prop6 => '6',
	);
	
	my $PS = $SiebelApp->NewPropertySet();
	isa_ok($PS,'Siebel::Integration::Com::PropSet', 'COM Siebel propset created 1');
	is($PS->Error, '', 'Com Siebel Propset created 2');

	my $PSChild1 = $SiebelApp->NewPropertySet();
	is($PSChild1->Error, '', 'Com Siebel Propset created 3');
	my $PSChild2 = $SiebelApp->NewPropertySet();
	is($PSChild2->Error, '', 'Com Siebel Propset created 4');
	my $PSChild3 = $SiebelApp->NewPropertySet();
	is($PSChild3->Error, '', 'Com Siebel Propset created 5');
	my $PSGrandChild1 = $SiebelApp->NewPropertySet();
	is($PSGrandChild1->Error, '', 'Com Siebel Propset created 6');
	my $PSGrandChild2 = $SiebelApp->NewPropertySet();
	is($PSGrandChild2->Error, '', 'Com Siebel Propset created 7');

	is($PS->GetPropertyCount(), 0, 'GetPropertyCount PS has no properties');
	
	is($PS->GetType(), '', 'GetType PS has no type');
	is($PS->GetValue(), '', 'GetValue PS has no value');

	ok($PS->SetType($props{Type}), "SetType PS has had its type set");
	is($PS->GetType(), $props{Type}, "GetType PS type value returned = type set");
	
	ok($PS->SetValue($props{Value}), "SetValue PS has had its value set");
	is($PS->GetValue(), $props{Value}, "GetValue PS type value returned = value set");

	ok($PS->SetProperty('Prop1', $props{Prop1}), "SetProperty PS has had property Prop1");
	ok($PS->SetProperty('Prop2', $props{Prop2}), "SetProperty PS has had property Prop2");
	ok($PS->SetProperty('Prop3', $props{Prop3}), "SetProperty PS has had property Prop3");
	ok($PS->SetProperty('Prop4', $props{Prop4}), "SetProperty PS has had property Prop4");
	ok($PS->SetProperty('Prop5', $props{Prop5}), "SetProperty PS has had property Prop5");
	ok($PS->SetProperty('Prop6', $props{Prop6}), "SetProperty PS has had property Prop6");

	is($PS->GetProperty('Prop1'), $props{Prop1}, "GetProperty PS has had property Prop1, This is Test Prop 1 Value set");

	is($PS->GetPropertyCount(), 6, 'GetPropertyCount PS has 6 properties');

	is($PS->PropertyExists('DoesNot'), 0, "PropertyExists PS Property does not Exist");
	is($PS->PropertyExists('Prop1'), 1, "PropertyExists PS Property does Exist");
	
	if(my $Prop = $PS->GetFirstProperty()){
		my $count;
		pass("GetFirstProperty PS");
		do{
			is($PS->GetProperty($Prop), $props{$Prop}, "GetProperty/GetNextProperty PS Input Prop = Output Prop: $Prop => $props{$Prop}");
			$count++;
		}while($Prop = $PS->GetNextProperty());
		is($count, 6, 'Correct number of props were looped with GetNextProperty');
	}else{
		fail("GetFirstProperty PS");
	}

	#load up child PS's
	foreach my $key(keys %props){
		ok($PSChild1->SetProperty($key, 'Child1:' . $props{$key}), "SetProperty Child1: $key");
		ok($PSChild2->SetProperty($key, 'Child2:' . $props{$key}), "SetProperty Child2:$key");
		ok($PSChild3->SetProperty($key, 'Child3:' . $props{$key}), "SetProperty Child3:$key");
		ok($PSGrandChild1->SetProperty($key, 'GrandChild1:' . $props{$key}), "SetProperty GrandChild1:$key");
		ok($PSGrandChild2->SetProperty($key, 'GrandChild2:' . $props{$key}), "SetProperty GrandChild2:$key");
	}
	
	is($PS->GetChildCount(), 0, "GetChildCount PS has no child");
	
	is($PSChild1->AddChild($PSGrandChild1), 0, "AddChild 1 as Siebel::Integration::Com::PropSet");#returns index
	is($PSChild1->AddChild($PSGrandChild1->_PS), 1, "AddChild 2 as Siebel raw PS (Win32::OLE)");#returns index
	is($PS->AddChild($PSChild1), 0, "AddChild 3 added prop set with a child to main PS as Siebel::Integration::Com::PropSet");#returns index
	is($PS->AddChild($PSChild2->_PS), 1, "AddChild 4 added prop set without a child to main PS as Siebel raw PS (Win32::OLE)");#returns index

	is($PS->GetChildCount(), 2, "GetChildCount PS has 2 children");

	ok($PS->InsertChildAt($PSChild3,0), "InsertChildAt index 0, Child 1 and 2 will now be in 2 and 3 pos");
	
	is($PS->GetChildCount(), 3, "GetChildCount PS has 3 children");

t/test.t  view on Meta::CPAN

		
		my $existingRecordId = "A";	
		if($BC_EmpCompAdmin->FirstRecord()){
			$existingRecordId = $BC_EmpCompAdmin->GetFieldValue('Id');
		}

		ok($BC_EmpCompAdmin->NewRecord('NewBefore'), "New Record BC_EmpCompAdmin NewBefore");
		#make sure new record exits by checking id is new
		if($BC_EmpCompAdmin->GetFieldValue('Id') eq $existingRecordId){
			fail('NewRecord failed to give a record with a new ROW_ID. Exiting: ' . $existingRecordId . ' New:' . $BC_EmpCompAdmin->GetFieldValue('Id'));
			return 'Error';
		}
		
		ok($BC_EmpCompAdmin->SetFieldValue('Employee Comments', 'Emp Comment'), "SetFieldValue Employee Comments " . $BC_EmpCompAdmin->Error);
		is($BC_EmpCompAdmin->GetFieldValue('Employee Comments'), 'Emp Comment', "GetFieldValue Employee Comments " . $BC_EmpCompAdmin->Error);
		
		SKIP: {
			skip('Test data not set for SetFormattedFieldValue methods', 2) if !defined $testData{FormattedDateTimeFieldValue};
			ok($BC_EmpCompAdmin->SetFormattedFieldValue('Date of Accomplishment', $testData{FormattedDateTimeFieldValue}), "SetFormattedFieldValue:" . $BC_EmpCompAdmin->Error);
			is($BC_EmpCompAdmin->GetFormattedFieldValue('Date of Accomplishment'), $testData{FormattedDateTimeFieldValue}, "GetFormattedFieldValue input: " . $testData{FormattedDateTimeFieldValue} . " Output: " . $BC_EmpCompAdmin->GetFormattedFieldValue('Date...
		}
		ok($BC_EmpCompAdmin->DeleteRecord, 'New Record Deleted Before Commit');
	}else{
		fail("No Records Found");
	}
	SKIP: {
		skip('Test data not set for GetAssocBusComp and Associate methods', 8) if !defined $testData{PositionIdToAssociate};
		my $MVGBC = $BC->GetMVGBusComp('Position Id');
		isa_ok($MVGBC,'Siebel::Integration::Com::BusComp', 'COM Siebel buscomp created GetMVGBusComp 1');
		is($MVGBC->Error, '', 'COM Siebel buscomp created GetMVGBusComp 2') || return 'Error';
	
		my $AssocMVG = $MVGBC->GetAssocBusComp();
		isa_ok($AssocMVG,'Siebel::Integration::Com::BusComp', 'COM Siebel buscomp created GetAssocBusComp 1');
		is($AssocMVG->Error, '', 'COM Siebel buscomp created GetAssocBusComp 2') || return 'Error';
		
		ok($AssocMVG->ClearToQuery(), "ClearToQuery"  . $AssocMVG->Error);
		ok($AssocMVG->SetSearchSpec('Id', $testData{PositionIdToAssociate}), "SetSearchSpec 'Id', " . $testData{PositionIdToAssociate} . $AssocMVG->Error);
		ok($AssocMVG->ExecuteQuery('ForwardOnly'), "ExecuteQuery ForwardOnly"  . $AssocMVG->Error) || return 'Error';
		if($AssocMVG->FirstRecord()){
			ok($AssocMVG->Associate('NewBefore'), 'Associate' . $AssocMVG->Error);
		}else{
			fail("No Assoc BC Records Found");
		}
	}
}

########################################################################################################################################################
###############################					END BC/BO RW TESTS						################################################################
########################################################################################################################################################

########################################################################################################################################################
###############################					START BS TESTS							################################################################
########################################################################################################################################################
sub TestBS{
	my $SiebelApp = shift;
	my $BS = $SiebelApp->GetService('Workflow Utilities');
	isa_ok($BS,'Siebel::Integration::Com::BusSrv', 'Business Service Workflow Utilities Created 1');
	is($BS->Error, '', 'Business Service Workflow Utilities Created 2') || return 'Error';
	
	my $PS = $SiebelApp->NewPropertySet();
	isa_ok($PS,'Siebel::Integration::Com::PropSet', 'COM Siebel propset created 1');
	is($PS->Error, '', 'Com Siebel Propset created 2');
	
	my $PSChild = $SiebelApp->NewPropertySet();
	isa_ok($PSChild,'Siebel::Integration::Com::PropSet', 'COM Siebel propset created 3');
	is($PSChild->Error, '', 'Com Siebel Propset created 4');
	
	my $Outputs = $SiebelApp->NewPropertySet();
	isa_ok($Outputs,'Siebel::Integration::Com::PropSet', 'COM Siebel propset created 5');
	is($Outputs->Error, '', 'Com Siebel Propset created 6');
	
	ok($PS->SetProperty('Prop Par 1', 'Prop Par 1 Value'), "SetProperty Par");
	ok($PS->SetType('This is a type'), "SetType Par");
	ok($PS->SetValue('And this is its value'),"SetValue Par");
	ok($PSChild->SetProperty('Prop Child 1', 'Prop Child 1 Value'), "SetProperty Child");
	is($PS->AddChild($PSChild),0,"AddChild");
	
	ok($BS->InvokeMethod('Echo', $PS, $Outputs),"Workflow Utilities Echo Method Called");
	
	is($Outputs->GetPropertyCount(), 1, 'Outputs: GetPropertyCount PS has 1 property');
	is($Outputs->GetType(), 'This is a type', "Outputs: GetType Parent PS");
	is($Outputs->GetValue(), 'And this is its value', "Outputs: GetValue Parent PS");

	is($Outputs->GetProperty('Prop Par 1'), 'Prop Par 1 Value', "Outputs: GetProperty Parent PS");
	is($Outputs->GetChildCount(), 1, "Outputs: GetChildCount Parent PS has 1");
	
	my $newChild = $Outputs->GetChild(0);
	is($newChild->GetChildCount(), 0, "Outputs: GetChildCount Child PS has 0");
	is($newChild->GetPropertyCount(), 1, 'Outputs: GetPropertyCount Child PS has 1 property');
	is($newChild->GetType(), '', "Outputs: GetType Child PS");
	is($newChild->GetValue(), '', "Outputs: GetValue Child PS");
	is($newChild->GetProperty('Prop Child 1'), 'Prop Child 1 Value', "Outputs: GetProperty Child PS");
	
	
}

########################################################################################################################################################
###############################					END BS TESTS							################################################################
########################################################################################################################################################



( run in 1.264 second using v1.01-cache-2.11-cpan-f56aa216473 )