@@ -289,7 +289,7 @@ public MockResponse dispatch(RecordedRequest request) {
289289 identifier , markDonePartitionsRequest .getPartitionSpecs ());
290290 return new MockResponse ().setResponseCode (200 );
291291 } else if (isPartitions ) {
292- return partitionsApiHandler (request , identifier );
292+ return partitionsApiHandle (request , identifier );
293293 } else if (isBranches ) {
294294 FileStoreTable table = (FileStoreTable ) catalog .getTable (identifier );
295295 BranchManager branchManager = table .branchManager ();
@@ -326,25 +326,25 @@ public MockResponse dispatch(RecordedRequest request) {
326326 return new MockResponse ().setResponseCode (404 );
327327 }
328328 } else if (isTableToken ) {
329- return handleDataToken (identifier );
329+ return getDataTokenHandle (identifier );
330330 } else if (isTableSnapshot ) {
331- return handleSnapshot (identifier );
331+ return snapshotHandle (identifier );
332332 } else if (isTableRename ) {
333- return renameTableApiHandler (request );
333+ return renameTableHandle (request );
334334 } else if (isTableCommit ) {
335- return commitTableApiHandler (request );
335+ return commitTableHandle (request );
336336 } else if (isTable ) {
337- return tableApiHandler (request , identifier );
337+ return tableHandle (request , identifier );
338338 } else if (isTables ) {
339- return tablesApiHandler (request , databaseName );
339+ return tablesHandle (request , databaseName );
340340 } else if (isViews ) {
341- return viewsApiHandler (request , databaseName );
341+ return viewsHandle (request , databaseName );
342342 } else if (isViewRename ) {
343- return renameViewApiHandler (request );
343+ return renameViewHandle (request );
344344 } else if (isView ) {
345- return viewApiHandler (request , identifier );
345+ return viewHandle (request , identifier );
346346 } else {
347- return databaseApiHandler (request , databaseName );
347+ return databaseHandle (request , databaseName );
348348 }
349349 }
350350 return new MockResponse ().setResponseCode (404 );
@@ -435,7 +435,7 @@ public MockResponse dispatch(RecordedRequest request) {
435435 };
436436 }
437437
438- private MockResponse handleDataToken (Identifier tableIdentifier ) throws Exception {
438+ private MockResponse getDataTokenHandle (Identifier tableIdentifier ) throws Exception {
439439 RESTToken dataToken = getDataToken (tableIdentifier );
440440 if (dataToken == null ) {
441441 long currentTimeMillis = System .currentTimeMillis () + 60_000 ;
@@ -456,7 +456,7 @@ private MockResponse handleDataToken(Identifier tableIdentifier) throws Exceptio
456456 .setBody (OBJECT_MAPPER .writeValueAsString (getTableTokenResponse ));
457457 }
458458
459- private MockResponse handleSnapshot (Identifier identifier ) throws Exception {
459+ private MockResponse snapshotHandle (Identifier identifier ) throws Exception {
460460 RESTResponse response ;
461461 Optional <Snapshot > snapshotOptional =
462462 Optional .ofNullable (tableSnapshotStore .get (identifier .getFullName ()));
@@ -492,7 +492,7 @@ private Optional<MockResponse> checkTablePartitioned(Identifier identifier) {
492492 new ErrorResponse (ErrorResponseResourceType .TABLE , null , "" , 404 ), 404 ));
493493 }
494494
495- private MockResponse commitTableApiHandler (RecordedRequest request ) throws Exception {
495+ private MockResponse commitTableHandle (RecordedRequest request ) throws Exception {
496496 CommitTableRequest requestBody =
497497 OBJECT_MAPPER .readValue (request .getBody ().readUtf8 (), CommitTableRequest .class );
498498 Identifier identifier = requestBody .getIdentifier ();
@@ -510,24 +510,6 @@ private MockResponse commitTableApiHandler(RecordedRequest request) throws Excep
510510 return mockResponse (response , 200 );
511511 }
512512
513- private FileStoreTable getFileTable (Identifier identifier ) {
514- TableMetadata tableMetadata = tableMetadataStore .get (identifier .getFullName ());
515- TableSchema schema = tableMetadata .schema ();
516- CatalogEnvironment catalogEnv =
517- new CatalogEnvironment (
518- identifier ,
519- tableMetadata .uuid (),
520- catalog .catalogLoader (),
521- catalog .lockFactory ().orElse (null ),
522- catalog .lockContext ().orElse (null ),
523- catalog instanceof SupportsSnapshots ,
524- catalog instanceof SupportsBranches );
525- Path path = new Path (schema .options ().get (PATH .key ()));
526- FileIO dataFileIO = catalog .fileIO ();
527- FileStoreTable table = FileStoreTableFactory .create (dataFileIO , path , schema , catalogEnv );
528- return table ;
529- }
530-
531513 private MockResponse databasesApiHandler (RecordedRequest request ) throws Exception {
532514 RESTResponse response ;
533515 switch (request .getMethod ()) {
@@ -550,7 +532,7 @@ private MockResponse databasesApiHandler(RecordedRequest request) throws Excepti
550532 }
551533 }
552534
553- private MockResponse databaseApiHandler (RecordedRequest request , String databaseName )
535+ private MockResponse databaseHandle (RecordedRequest request , String databaseName )
554536 throws Exception {
555537 RESTResponse response ;
556538 Database database ;
@@ -611,7 +593,7 @@ private MockResponse databaseApiHandler(RecordedRequest request, String database
611593 return new MockResponse ().setResponseCode (404 );
612594 }
613595
614- private MockResponse tablesApiHandler (RecordedRequest request , String databaseName )
596+ private MockResponse tablesHandle (RecordedRequest request , String databaseName )
615597 throws Exception {
616598 RESTResponse response ;
617599 if (databaseStore .containsKey (databaseName )) {
@@ -660,7 +642,7 @@ private boolean isFormatTable(Schema schema) {
660642 return Options .fromMap (schema .options ()).get (TYPE ) == FORMAT_TABLE ;
661643 }
662644
663- private MockResponse tableApiHandler (RecordedRequest request , Identifier identifier )
645+ private MockResponse tableHandle (RecordedRequest request , Identifier identifier )
664646 throws Exception {
665647 RESTResponse response ;
666648 if (tableMetadataStore .containsKey (identifier .getFullName ())) {
@@ -697,7 +679,7 @@ private MockResponse tableApiHandler(RecordedRequest request, Identifier identif
697679 }
698680 }
699681
700- private MockResponse renameTableApiHandler (RecordedRequest request ) throws Exception {
682+ private MockResponse renameTableHandle (RecordedRequest request ) throws Exception {
701683 RenameTableRequest requestBody =
702684 OBJECT_MAPPER .readValue (request .getBody ().readUtf8 (), RenameTableRequest .class );
703685 Identifier fromTable = requestBody .getSource ();
@@ -715,7 +697,7 @@ private MockResponse renameTableApiHandler(RecordedRequest request) throws Excep
715697 return new MockResponse ().setResponseCode (200 );
716698 }
717699
718- private MockResponse partitionsApiHandler (RecordedRequest request , Identifier tableIdentifier )
700+ private MockResponse partitionsApiHandle (RecordedRequest request , Identifier tableIdentifier )
719701 throws Exception {
720702 RESTResponse response ;
721703 switch (request .getMethod ()) {
@@ -739,7 +721,7 @@ private MockResponse partitionsApiHandler(RecordedRequest request, Identifier ta
739721 }
740722 }
741723
742- private MockResponse viewsApiHandler (RecordedRequest request , String databaseName )
724+ private MockResponse viewsHandle (RecordedRequest request , String databaseName )
743725 throws Exception {
744726 RESTResponse response ;
745727 switch (request .getMethod ()) {
@@ -778,7 +760,7 @@ private MockResponse viewsApiHandler(RecordedRequest request, String databaseNam
778760 }
779761 }
780762
781- private MockResponse viewApiHandler (RecordedRequest request , Identifier identifier )
763+ private MockResponse viewHandle (RecordedRequest request , Identifier identifier )
782764 throws Exception {
783765 RESTResponse response ;
784766 if (viewStore .containsKey (identifier .getFullName ())) {
@@ -807,7 +789,7 @@ private MockResponse viewApiHandler(RecordedRequest request, Identifier identifi
807789 throw new Catalog .ViewNotExistException (identifier );
808790 }
809791
810- private MockResponse renameViewApiHandler (RecordedRequest request ) throws Exception {
792+ private MockResponse renameViewHandle (RecordedRequest request ) throws Exception {
811793 RenameTableRequest requestBody =
812794 OBJECT_MAPPER .readValue (request .getBody ().readUtf8 (), RenameTableRequest .class );
813795 Identifier fromView = requestBody .getSource ();
@@ -978,4 +960,22 @@ private Partition spec2Partition(Map<String, String> spec) {
978960 // todo: need update
979961 return new Partition (spec , 123 , 456 , 789 , 123 );
980962 }
963+
964+ private FileStoreTable getFileTable (Identifier identifier ) {
965+ TableMetadata tableMetadata = tableMetadataStore .get (identifier .getFullName ());
966+ TableSchema schema = tableMetadata .schema ();
967+ CatalogEnvironment catalogEnv =
968+ new CatalogEnvironment (
969+ identifier ,
970+ tableMetadata .uuid (),
971+ catalog .catalogLoader (),
972+ catalog .lockFactory ().orElse (null ),
973+ catalog .lockContext ().orElse (null ),
974+ catalog instanceof SupportsSnapshots ,
975+ catalog instanceof SupportsBranches );
976+ Path path = new Path (schema .options ().get (PATH .key ()));
977+ FileIO dataFileIO = catalog .fileIO ();
978+ FileStoreTable table = FileStoreTableFactory .create (dataFileIO , path , schema , catalogEnv );
979+ return table ;
980+ }
981981}
0 commit comments