Project

General

Profile

« Previous | Next » 

Revision 892efc69

Added by Andreas Kohlbecker almost 14 years ago

merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk

View differences:

cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmGenericDaoImplTest.java
198 198
	@SpringBeanByType
199 199
	private IAgentDao agentDao;
200 200
	
201
	ReferenceFactory refFactory = ReferenceFactory.newInstance();
201
	
202 202
	/**
203 203
	 * @throws java.lang.Exception
204 204
	 */
......
232 232
	@Test
233 233
	@Ignore
234 234
	public void testDelete(){
235
		ReferenceBase ref1 = refFactory.newBook();
236
		ReferenceBase ref2 = refFactory.newBook();
235
		ReferenceBase ref1 = ReferenceFactory.newBook();
236
		ReferenceBase ref2 = ReferenceFactory.newBook();
237 237
		Annotation annotation = Annotation.NewInstance("Anno1", null);
238 238
		ref1.addAnnotation(annotation);
239 239
		cdmGenericDao.saveOrUpdate(ref1);
......
260 260
	@Ignore
261 261
	public void testDelete2() throws MergeException {
262 262
		BotanicalName name1 = BotanicalName.NewInstance(Rank.SPECIES());
263
		name1.setTitleCache("BotanicalName1");
263
		name1.setTitleCache("BotanicalName1", true);
264 264
		
265 265
		BotanicalName name2 = BotanicalName.NewInstance(Rank.SPECIES());
266
		name2.setTitleCache("BotanicalName2");
266
		name2.setTitleCache("BotanicalName2", true);
267 267
		
268
		ReferenceBase article1 = refFactory.newArticle();
269
		ReferenceBase article2 = refFactory.newArticle();
268
		ReferenceBase article1 = ReferenceFactory.newArticle();
269
		ReferenceBase article2 = ReferenceFactory.newArticle();
270 270
		
271 271
		
272 272
		name1.setNomenclaturalReference(article1);
......
497 497
	@Test
498 498
	public void testGetReferencingObjectsCdmBase() {
499 499
		BotanicalName name = BotanicalName.NewInstance(Rank.SPECIES());
500
		name.setTitleCache("A name");
501
		ReferenceBase ref1 = refFactory.newArticle();
500
		name.setTitleCache("A name", true);
501
		ReferenceBase ref1 = ReferenceFactory.newArticle();
502 502
		Taxon taxon = Taxon.NewInstance(name, ref1);
503 503
		Person author = Person.NewInstance();
504
		author.setTitleCache("Author");
504
		author.setTitleCache("Author", true);
505 505
		ref1.addAnnotation(Annotation.NewInstance("A1", Language.DEFAULT()));
506 506
		ref1.setAuthorTeam(author);
507 507
		name.setBasionymAuthorTeam(author);
......
578 578
		
579 579
		
580 580
		BotanicalName name1 = BotanicalName.NewInstance(Rank.SPECIES());
581
		name1.setTitleCache("BotanicalName1");
581
		name1.setTitleCache("BotanicalName1", true);
582 582
		
583 583
		BotanicalName name2 = BotanicalName.NewInstance(Rank.SPECIES());
584
		name2.setTitleCache("BotanicalName2");
584
		name2.setTitleCache("BotanicalName2", true);
585 585
		
586 586
		ZoologicalName zooName1 = ZoologicalName.NewInstance(Rank.SPECIES());
587
		name1.setTitleCache("ZoologicalName1");
587
		name1.setTitleCache("ZoologicalName1", true);
588 588

  
589
		ReferenceBase article1 = refFactory.newArticle();
590
		ReferenceBase article2 = refFactory.newArticle();
589
		ReferenceBase article1 = ReferenceFactory.newArticle();
590
		ReferenceBase article2 = ReferenceFactory.newArticle();
591 591
		
592 592
		
593 593
		name1.setNomenclaturalReference(article1);
......
653 653
		nameDao.save(zooName1);
654 654
		
655 655
		TaxonDescription taxDesc = TaxonDescription.NewInstance(taxon1);
656
		taxDesc.setTitleCache("taxDesc");
656
		taxDesc.setTitleCache("taxDesc", true);
657 657
		taxDesc.addDescriptionSource(article2);
658 658

  
659 659
		taxonDao.save(taxon1);
......
707 707
	@Ignore
708 708
	public void testMergeTaxonNameAndTaxon() throws MergeException {
709 709
		BotanicalName name1 = BotanicalName.NewInstance(Rank.SPECIES());
710
		name1.setTitleCache("BotanicalName1");
710
		name1.setTitleCache("BotanicalName1", true);
711 711
		
712 712
		BotanicalName name2 = BotanicalName.NewInstance(Rank.SPECIES());
713
		name2.setTitleCache("BotanicalName2");
713
		name2.setTitleCache("BotanicalName2", true);
714 714

  
715 715
		BotanicalName name3 = BotanicalName.NewInstance(Rank.SPECIES());
716
		name3.setTitleCache("BotanicalName3");
716
		name3.setTitleCache("BotanicalName3", true);
717 717
		
718
		ReferenceBase database = refFactory.newDatabase();
718
		ReferenceBase database = ReferenceFactory.newDatabase();
719 719
		
720 720
		Taxon taxon1 = Taxon.NewInstance(name1, database);
721 721
		Taxon taxon2 = Taxon.NewInstance(name2, database);
......
744 744
	public void testMergeAuthors() throws MergeException {
745 745
		
746 746
		BotanicalName name1 = BotanicalName.NewInstance(Rank.SPECIES());
747
		name1.setTitleCache("BotanicalName1");
747
		name1.setTitleCache("BotanicalName1", true);
748 748
		
749 749
		BotanicalName name2 = BotanicalName.NewInstance(Rank.SPECIES());
750
		name2.setTitleCache("BotanicalName2");
750
		name2.setTitleCache("BotanicalName2", true);
751 751

  
752
		IBook book1 = refFactory.newBook();
753
		IBook book2 = refFactory.newBook();
752
		IBook book1 = ReferenceFactory.newBook();
753
		IBook book2 = ReferenceFactory.newBook();
754 754
		
755 755
		Team team1 = Team.NewInstance();
756 756
		Team team2 = Team.NewInstance();
757 757
		Team team3 = Team.NewInstance();
758
		team1.setTitleCache("team1");
759
		team2.setTitleCache("team2");
760
		team3.setTitleCache("team3");
758
		team1.setTitleCache("team1", true);
759
		team2.setTitleCache("team2", true);
760
		team3.setTitleCache("team3", true);
761 761
		
762 762
		Person person1 = Person.NewTitledInstance("person1");
763 763
		Person person2 = Person.NewTitledInstance("person2");
......
831 831
		
832 832
		//Person
833 833
		Institution institution1 = Institution.NewInstance();
834
		institution1.setTitleCache("inst1");
834
		institution1.setTitleCache("inst1", true);
835 835
		Institution institution2 = Institution.NewInstance();
836
		institution2.setTitleCache("inst2");
836
		institution2.setTitleCache("inst2", true);
837 837
		
838 838
		TimePeriod period1 = TimePeriod.NewInstance(2002, 2004);
839 839
		TimePeriod period2 = TimePeriod.NewInstance(2004, 2006);
......
884 884
	
885 885
	@Test
886 886
	public void findMatching(){
887
		IBook book1 = refFactory.newBook();
888
		IBook book2 = refFactory.newBook();
889
		IBook book3 = refFactory.newBook();
890
		IBook book4 = refFactory.newBook();
887
		IBook book1 = ReferenceFactory.newBook();
888
		IBook book2 = ReferenceFactory.newBook();
889
		IBook book3 = ReferenceFactory.newBook();
890
		IBook book4 = ReferenceFactory.newBook();
891 891
		
892 892
		String title1 = "title1";
893 893
		String title2 = "title2";
......
921 921
			Assert.assertSame("Resultlist entry must be book 1", book1, matchResult.get(0));
922 922
			
923 923
			//BookSection
924
			IBookSection section1 = refFactory.newBookSection();
924
			IBookSection section1 = ReferenceFactory.newBookSection();
925 925
			section1.setInBook(book1);
926 926
			section1.setTitle("SecTitle");
927 927
			section1.setPages("22-33");
928
			IBookSection section2 = refFactory.newBookSection();
928
			IBookSection section2 = ReferenceFactory.newBookSection();
929 929
			section2.setInBook(book2);
930 930
			section2.setTitle("SecTitle");
931 931
			section2.setPages("22-33");
932
			IBookSection section3 = refFactory.newBookSection();
932
			IBookSection section3 = ReferenceFactory.newBookSection();
933 933
			section3.setInBook(book1);
934 934
			section3.setTitle("SecTitle");
935 935
			section3.setPages("22-33");
......
958 958
			person2.setPrefix("pre2");
959 959
			person3.setPrefix("pre3");
960 960
			
961
//			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
962
//			Assert.assertEquals("Resultlist must have 2 entries", 2, matchResult.size());
963
			
961 964
			book1.setAuthorTeam(person1);
962 965
			book2.setAuthorTeam(person1);
963 966
			book3.setAuthorTeam(person1);
967
			
968
			boolean m = matchStrategy.invoke(book1, book3);
969
			boolean m2 = matchStrategy.invoke(book2, book3);
970
			
964 971
			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
965 972
			Assert.assertEquals("Resultlist must have 2 entries", 2, matchResult.size());
966 973
			
......
984 991
	
985 992
	@Test
986 993
	public void findMatchingCache(){
987
		IBook book1 = refFactory.newBook();
994
		IBook book1 = ReferenceFactory.newBook();
988 995
		Team team1 = Team.NewInstance();
989 996
		Team team2 = Team.NewInstance();
990
		team1.setTitleCache("Team1");
991
		team2.setTitleCache("Team1");
997
		team1.setTitleCache("Team1", true);
998
		team2.setTitleCache("Team1", true);
992 999
		
993 1000
		book1.setTitle("Title1");
994 1001
		book1.setEdition("Edition1");
......
1028 1035
			Assert.assertTrue("Resultlist must contain book 1", matchResult.contains(book1));
1029 1036
			Assert.assertTrue("Resultlist must contain book 2", matchResult.contains(book2));
1030 1037
			
1031
			book1.setTitleCache("cache1");
1038
			book1.setTitleCache("cache1", true);
1032 1039
			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
1033 1040
			Assert.assertEquals("Resultlist must have 1 entries", 1, matchResult.size());
1034 1041
			Assert.assertTrue("Resultlist must contain book 2", matchResult.contains(book2));
......
1042 1049
			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
1043 1050
			Assert.assertEquals("Resultlist must have 0 entries", 0, matchResult.size());
1044 1051
			
1045
			book3.setTitleCache("cache1");
1052
			book3.setTitleCache("cache1", true);
1046 1053
			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
1047 1054
			Assert.assertEquals("Resultlist must have 1 entries", 1, matchResult.size());
1048 1055
			Assert.assertTrue("Resultlist must contain book 1", matchResult.contains(book1));
......
1061 1068
			Assert.assertEquals("Resultlist must have 1 entries", 1, matchResult.size());
1062 1069
			Assert.assertTrue("Resultlist must contain book 1", matchResult.contains(book1));
1063 1070
			
1064
			book2.setTitleCache(book3.getTitleCache());
1071
			book2.setTitleCache(book3.getTitleCache(), true);
1065 1072
			matchResult = cdmGenericDao.findMatching(book3, matchStrategy);
1066 1073
			Assert.assertEquals("Resultlist must have 2 entries", 2, matchResult.size());
1067 1074
			Assert.assertTrue("Resultlist must contain book 1", matchResult.contains(book1));
1068 1075
			Assert.assertTrue("Resultlist must contain book 2", matchResult.contains(book2));
1069 1076
			
1070
			team2.setTitleCache("team2");
1077
			team2.setTitleCache("team2", true);
1071 1078
			teamsMatch = teamMatcher.invoke(team1, team2);
1072 1079
			Assert.assertFalse("Team1 and team2 should not match" ,teamsMatch);
1073 1080
			

Also available in: Unified diff