### Question:
EventUtils { public static EventPartitions toEventPartitions(Table table, List<Partition> partitions) { LinkedHashMap<String, String> partitionKeyTypes = new LinkedHashMap<>(); List<FieldSchema> partitionKeys = table.getPartitionKeys(); for (FieldSchema partitionKey : partitionKeys) { partitionKeyTypes.put(partitionKey.getName(), partitionKey.getType()); } EventPartitions eventPartitions = new EventPartitions(partitionKeyTypes); if (partitions != null) { for (Partition partition : partitions) { eventPartitions.add(new EventPartition(partition.getValues(), LocationUtils.hasLocation(partition) ? LocationUtils.locationAsUri(partition) : null)); } } return eventPartitions; } private  EventUtils(); static List<URI> toUris(List<Path> paths); static EventPartitions toEventPartitions(Table table, List<Partition> partitions); static EventTable toEventTable(Table sourceTable); static EventSourceCatalog toEventSourceCatalog(SourceCatalog sourceCatalog); static EventReplicaCatalog toEventReplicaCatalog(ReplicaCatalog replicaCatalog, Security security); static EventTableReplication toEventTableReplication(TableReplication tableReplication); static final String EVENT_ID_UNAVAILABLE; }### Answer:
@Test public void toNullEventPartitions() { EventPartitions eventPartitions = EventUtils.toEventPartitions(table, null); assertThat(eventPartitions.getEventPartitions().size(), is(0)); }
@Test public void toEmptyEventPartitions() { EventPartitions eventPartitions = EventUtils.toEventPartitions(table, Collections.<Partition> emptyList()); List<EventPartition> partitions = eventPartitions.getEventPartitions(); assertThat(partitions, is(not(nullValue()))); assertThat(partitions.size(), is(0)); assertPartitionKeyTypes(eventPartitions.getPartitionKeyTypes()); }
@Test public void toEventPartitions() { when(partitionStorageDescriptor.getLocation()).thenReturn("location"); EventPartitions eventPartitions = EventUtils.toEventPartitions(table, ImmutableList.of(partition)); List<EventPartition> partitions = eventPartitions.getEventPartitions(); assertThat(partitions, is(not(nullValue()))); assertThat(partitions.size(), is(1)); assertThat(partitions.get(0).getValues(), is(PARTITION_VALUES)); assertThat(partitions.get(0).getLocation(), is(URI.create("location"))); assertPartitionKeyTypes(eventPartitions.getPartitionKeyTypes()); }
@Test public void toEventPartitionsWithNullLocation() { EventPartitions eventPartitions = EventUtils.toEventPartitions(table, ImmutableList.of(partition)); List<EventPartition> partitions = eventPartitions.getEventPartitions(); assertThat(partitions, is(not(nullValue()))); assertThat(partitions.size(), is(1)); assertThat(partitions.get(0).getValues(), is(PARTITION_VALUES)); assertThat(partitions.get(0).getLocation(), is(nullValue())); }