### Question:
TableMetadata implements Serializable { public SortOrder sortOrder() { return sortOrdersById.get(defaultSortOrderId); } @SuppressWarnings("checkstyle:CyclomaticComplexity")  TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                int defaultSortOrderId,
                List<SortOrder> sortOrders,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); @Deprecated static TableMetadata newTableMetadata(TableOperations ops,
                                               Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               SortOrder sortOrder,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); int formatVersion(); String metadataFileLocation(); String uuid(); long lastSequenceNumber(); long nextSequenceNumber(); long lastUpdatedMillis(); int lastColumnId(); Schema schema(); PartitionSpec spec(); PartitionSpec spec(int id); List<PartitionSpec> specs(); Map<Integer, PartitionSpec> specsById(); int defaultSpecId(); int defaultSortOrderId(); SortOrder sortOrder(); List<SortOrder> sortOrders(); Map<Integer, SortOrder> sortOrdersById(); String location(); Map<String, String> properties(); String property(String property, String defaultValue); boolean propertyAsBoolean(String property, boolean defaultValue); int propertyAsInt(String property, int defaultValue); long propertyAsLong(String property, long defaultValue); Snapshot snapshot(long snapshotId); Snapshot currentSnapshot(); List<Snapshot> snapshots(); List<HistoryEntry> snapshotLog(); List<MetadataLogEntry> previousFiles(); TableMetadata withUUID(); TableMetadata updateSchema(Schema newSchema, int newLastColumnId); TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec); TableMetadata updateSortOrder(SortOrder newOrder); TableMetadata addStagedSnapshot(Snapshot snapshot); TableMetadata replaceCurrentSnapshot(Snapshot snapshot); TableMetadata removeSnapshotsIf(Predicate<Snapshot> removeIf); TableMetadata replaceProperties(Map<String, String> newProperties); TableMetadata removeSnapshotLogEntries(Set<Long> snapshotIds); TableMetadata buildReplacement(Schema updatedSchema, PartitionSpec updatedPartitionSpec,
                                        SortOrder updatedSortOrder, String newLocation,
                                        Map<String, String> updatedProperties); TableMetadata updateLocation(String newLocation); TableMetadata upgradeToFormatVersion(int newFormatVersion);  }### Answer:
@Test public void testSortOrder() { Schema schema = new Schema( Types.NestedField.required(10, "x", Types.StringType.get()) ); TableMetadata meta = TableMetadata.newTableMetadata( schema, PartitionSpec.unpartitioned(), null, ImmutableMap.of()); Assert.assertTrue("Should default to unsorted order", meta.sortOrder().isUnsorted()); Assert.assertSame("Should detect identical unsorted order", meta, meta.updateSortOrder(SortOrder.unsorted())); }