void InsertProjectTester::testExistingResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); QVERIFY( p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }
void InsertProjectTester::testTeamResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); r->setType( Resource::Type_Team ); ResourceGroup *tg = addResourceGroup( part ); Resource *t1 = addResource( part, tg ); r->addTeamMemberId( t1->id() ); Resource *t2 = addResource( part, tg ); r->addTeamMemberId( t2->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); qDebug()<<"Start test:"; Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( part.getProject(), 0, 0 ); Project &p2 = part2.getProject(); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource(), r ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); }
void InsertProjectTester::testExistingTeamResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); r->setName( "R1" ); r->setType( Resource::Type_Team ); ResourceGroup *tg = addResourceGroup( part ); tg->setName( "TG" ); Resource *t1 = addResource( part, tg ); t1->setName( "T1" ); r->addTeamMemberId( t1->id() ); Resource *t2 = addResource( part, tg ); t2->setName( "T2" ); r->addTeamMemberId( t2->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); Project &p2 = part2.getProject(); part2.insertProject( part.getProject(), 0, 0 ); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); QCOMPARE( p2.numChildren(), 2 ); QVERIFY( ! p2.childNode( 0 )->requests().isEmpty() ); rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); QVERIFY( ! p2.childNode( 1 )->requests().isEmpty() ); rr = p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); }
void InsertProjectTester::testResourceRequest() { Part part; addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); Project &p = part.getProject(); Part part2; part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }
void InsertProjectTester::testExistingRequiredResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); ResourceGroup *g = addResourceGroup( part ); g->setType( ResourceGroup::Type_Material ); QList<Resource*> m; m << addResource( part, g ); m.first()->setType( Resource::Type_Material ); r->setRequiredIds( QStringList() << m.first()->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); rr = p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); }
void InsertProjectTester::testResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }