Project

General

Profile

« Previous | Next » 

Revision 9088

Added by Jing Tao about 9 years ago

Add two more test cases. Refer https://redmine.dataone.org/issues/6734.

View differences:

SIDTest.java
133 133
	    testCase13();
134 134
	    testCase14();
135 135
	    testCase15();
136
	    testCase16();
137
        testCase17();
136 138
	}
137 139
	
138 140
	/**
......
764 766
	}
765 767
	
766 768
	/**
767
     * case 15. P1(S1) <-> P2(S1)  ?? <- P4(S1) <-> P5(S2), S1 = P2 (Rule 1)  oops!, should be s1=P4
769
     * case 15. P1(S1) <-> P2(S1)  ?? <- P4(S1) <-> P5(S2), S1 = P4 (Rule 1) 
768 770
     * @throws Exception
769 771
     */
770 772
    private void testCase15() throws Exception {
......
820 822
        //System.out.println("The head is "+head.getValue());
821 823
        assertTrue(head.equals(p4));
822 824
    }
825
    
826
    /**
827
     * case 16. P1(S1) <- P2(S1) -> ?? <-P4(S2) S1 = P2 (two ends, not an ideal chain), S2=P4 (rule1)
828
     * @throws Exception
829
     */
830
    private void testCase16() throws Exception {
831
        Identifier s1 = new Identifier();
832
        s1.setValue("S1");
833
        Identifier s2 = new Identifier();
834
        s2.setValue("S2");
835
        Identifier p1 = new Identifier();
836
        p1.setValue("P1");
837
        Identifier p2 = new Identifier();
838
        p2.setValue("P2");
839
        Identifier p3 = new Identifier();
840
        p3.setValue("P3");
841
        Identifier p4 = new Identifier();
842
        p4.setValue("P4");
843
       
844
        
845
        SystemMetadata p1Sys = new SystemMetadata();
846
        p1Sys.setIdentifier(p1);
847
        p1Sys.setSeriesId(s1);
848
        //p1Sys.setObsoletedBy(p2);
849
        p1Sys.setDateUploaded(new Date(100));
850
        
851
        SystemMetadata p2Sys = new SystemMetadata();
852
        p2Sys.setIdentifier(p2);
853
        p2Sys.setSeriesId(s1);
854
        p2Sys.setObsoletes(p1);
855
        p2Sys.setObsoletedBy(p3);
856
        p2Sys.setDateUploaded(new Date(200));
857
        
858
        SystemMetadata p4Sys = new SystemMetadata();
859
        p4Sys.setIdentifier(p4);
860
        p4Sys.setSeriesId(s2);
861
        p4Sys.setObsoletes(p3);
862
        p4Sys.setDateUploaded(new Date(400));
863
        
864
 
865
        
866
        Vector<SystemMetadata> chain = new Vector<SystemMetadata>();
867
        chain.add(p1Sys);
868
        chain.add(p2Sys);
869
        chain.add(p4Sys);
870
        
871
        
872
        System.out.println("Case 16:");
873
        Identifier head = getHeadVersion(s1, chain);
874
        //System.out.println("The head is "+head.getValue());
875
        assertTrue(head.equals(p2));
876
        Identifier head2 = getHeadVersion(s2, chain);
877
        //System.out.println("The head is "+head.getValue());
878
        assertTrue(head2.equals(p4));
879
    }
880
    
881
    /**
882
     * case 17. P1(S1) <- P2(S1) -> ?? <-P4(S1) S1 = P4 (P1 and P4 are two ends, not an ideal chain)
883
     * @throws Exception
884
     */
885
    private void testCase17() throws Exception {
886
        Identifier s1 = new Identifier();
887
        s1.setValue("S1");
888
        Identifier s2 = new Identifier();
889
        s2.setValue("S2");
890
        Identifier p1 = new Identifier();
891
        p1.setValue("P1");
892
        Identifier p2 = new Identifier();
893
        p2.setValue("P2");
894
        Identifier p3 = new Identifier();
895
        p3.setValue("P3");
896
        Identifier p4 = new Identifier();
897
        p4.setValue("P4");
898
       
899
        
900
        SystemMetadata p1Sys = new SystemMetadata();
901
        p1Sys.setIdentifier(p1);
902
        p1Sys.setSeriesId(s1);
903
        //p1Sys.setObsoletedBy(p2);
904
        p1Sys.setDateUploaded(new Date(100));
905
        
906
        SystemMetadata p2Sys = new SystemMetadata();
907
        p2Sys.setIdentifier(p2);
908
        p2Sys.setSeriesId(s1);
909
        p2Sys.setObsoletes(p1);
910
        p2Sys.setObsoletedBy(p3);
911
        p2Sys.setDateUploaded(new Date(200));
912
        
913
        SystemMetadata p4Sys = new SystemMetadata();
914
        p4Sys.setIdentifier(p4);
915
        p4Sys.setSeriesId(s1);
916
        p4Sys.setObsoletes(p3);
917
        p4Sys.setDateUploaded(new Date(400));
918
        
919
 
920
        
921
        Vector<SystemMetadata> chain = new Vector<SystemMetadata>();
922
        chain.add(p1Sys);
923
        chain.add(p2Sys);
924
        chain.add(p4Sys);
925
        
926
        
927
        System.out.println("Case 17:");
928
        Identifier head = getHeadVersion(s1, chain);
929
        //System.out.println("The head is "+head.getValue());
930
        assertTrue(head.equals(p4));
931
      
932
    }
823 933
	
824 934
	
825 935
	/*

Also available in: Unified diff