23
23
import sleeper .core .schema .type .LongType ;
24
24
import sleeper .core .statestore .AllReferencesToAFile ;
25
25
import sleeper .core .statestore .AllReferencesToAllFiles ;
26
+ import sleeper .core .statestore .CheckFileAssignmentsRequest ;
26
27
import sleeper .core .statestore .FileReference ;
27
28
import sleeper .core .statestore .SplitFileReferenceRequest ;
28
29
import sleeper .core .statestore .SplitFileReferences ;
@@ -597,7 +598,8 @@ void shouldFilesNotYetAssigned() throws Exception {
597
598
store .addFiles (List .of (file1 , file2 ));
598
599
599
600
// When / Then
600
- assertThat (store .isPartitionFilesAssignedToJob ("root" , List .of ("file1" , "file2" ), "test-job" ))
601
+ assertThat (store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
602
+ "test-job" , List .of ("file1" , "file2" ), "root" ))))
601
603
.isFalse ();
602
604
}
603
605
@@ -610,7 +612,8 @@ void shouldCheckAllFilesAssigned() throws Exception {
610
612
store .assignJobIds (List .of (assignJobOnPartitionToFiles ("test-job" , "root" , List .of ("file1" , "file2" ))));
611
613
612
614
// When / Then
613
- assertThat (store .isPartitionFilesAssignedToJob ("root" , List .of ("file1" , "file2" ), "test-job" ))
615
+ assertThat (store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
616
+ "test-job" , List .of ("file1" , "file2" ), "root" ))))
614
617
.isTrue ();
615
618
}
616
619
@@ -623,7 +626,8 @@ void shouldCheckSomeFilesAssigned() throws Exception {
623
626
store .assignJobIds (List .of (assignJobOnPartitionToFiles ("test-job" , "root" , List .of ("file1" ))));
624
627
625
628
// When / Then
626
- assertThat (store .isPartitionFilesAssignedToJob ("root" , List .of ("file1" , "file2" ), "test-job" ))
629
+ assertThat (store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
630
+ "test-job" , List .of ("file1" , "file2" ), "root" ))))
627
631
.isFalse ();
628
632
}
629
633
@@ -641,16 +645,19 @@ void shouldCheckFilesAssignedOnOnePartition() throws Exception {
641
645
store .assignJobIds (List .of (assignJobOnPartitionToFiles ("test-job" , "L" , List .of ("file1" , "file2" ))));
642
646
643
647
// When / Then
644
- assertThat (store .isPartitionFilesAssignedToJob ("R" , List .of ("file1" , "file2" ), "test-job" ))
648
+ assertThat (store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
649
+ "test-job" , List .of ("file1" , "file2" ), "R" ))))
645
650
.isFalse ();
646
- assertThat (store .isPartitionFilesAssignedToJob ("L" , List .of ("file1" , "file2" ), "test-job" ))
651
+ assertThat (store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
652
+ "test-job" , List .of ("file1" , "file2" ), "L" ))))
647
653
.isTrue ();
648
654
}
649
655
650
656
@ Test
651
657
void shouldFailIfFileDoesNotExist () {
652
658
// When / Then
653
- assertThatThrownBy (() -> store .isPartitionFilesAssignedToJob ("root" , List .of ("file" ), "test-job" ))
659
+ assertThatThrownBy (() -> store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
660
+ "test-job" , List .of ("file" ), "root" ))))
654
661
.isInstanceOf (FileReferenceNotFoundException .class );
655
662
}
656
663
@@ -661,7 +668,8 @@ void shouldFailIfFileDoesNotExistOnPartition() throws Exception {
661
668
store .addFile (factory .partitionFile ("L" , "file" , 100L ));
662
669
663
670
// When / Then
664
- assertThatThrownBy (() -> store .isPartitionFilesAssignedToJob ("R" , List .of ("file" ), "test-job" ))
671
+ assertThatThrownBy (() -> store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
672
+ "test-job" , List .of ("file" ), "R" ))))
665
673
.isInstanceOf (FileReferenceNotFoundException .class );
666
674
}
667
675
@@ -672,7 +680,8 @@ void shouldFailIfFileAssignedToOtherJob() throws Exception {
672
680
store .assignJobIds (List .of (assignJobOnPartitionToFiles ("A" , "root" , List .of ("file" ))));
673
681
674
682
// When / Then
675
- assertThatThrownBy (() -> store .isPartitionFilesAssignedToJob ("root" , List .of ("file" ), "B" ))
683
+ assertThatThrownBy (() -> store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
684
+ "B" , List .of ("file" ), "root" ))))
676
685
.isInstanceOf (FileReferenceAssignedToJobException .class );
677
686
}
678
687
@@ -682,7 +691,8 @@ void shouldFailIfOneFileDoesNotExist() throws Exception {
682
691
store .addFile (factory .rootFile ("file1" , 100L ));
683
692
684
693
// When / Then
685
- assertThatThrownBy (() -> store .isPartitionFilesAssignedToJob ("root" , List .of ("file1" , "file2" ), "test-job" ))
694
+ assertThatThrownBy (() -> store .isAssigned (List .of (CheckFileAssignmentsRequest .isJobAssignedToFilesOnPartition (
695
+ "test-job" , List .of ("file1" , "file2" ), "root" ))))
686
696
.isInstanceOf (FileReferenceNotFoundException .class );
687
697
}
688
698
}
0 commit comments