### Question:
ApiaryGlueSync extends MetaStoreEventListener { @Override public void onCreateTable(CreateTableEvent event) throws MetaException { if (event.getStatus() == false) { return; } Table table = event.getTable(); try { CreateTableRequest createTableRequest = new CreateTableRequest() .withTableInput(transformTable(table)) .withDatabaseName(glueDbName(table)); glueClient.createTable(createTableRequest); log.debug(table + " table created in glue catalog"); } catch (AlreadyExistsException e) { log.debug(table + " table already exists in glue, updating...."); UpdateTableRequest updateTableRequest = new UpdateTableRequest() .withTableInput(transformTable(table)) .withDatabaseName(glueDbName(table)); glueClient.updateTable(updateTableRequest); log.debug(table + " table updated in glue catalog"); } } ApiaryGlueSync(Configuration config);  ApiaryGlueSync(Configuration config, AWSGlue glueClient, String gluePrefix); @Override void onCreateTable(CreateTableEvent event); @Override void onDropTable(DropTableEvent event); @Override void onAlterTable(AlterTableEvent event); @Override void onAddPartition(AddPartitionEvent event); @Override void onDropPartition(DropPartitionEvent event); @Override void onAlterPartition(AlterPartitionEvent event);  }### Answer:
@Test public void onCreateTable() throws MetaException { CreateTableEvent event = mock(CreateTableEvent.class); when(event.getStatus()).thenReturn(true); Table table = new Table(); table.setTableName(tableName); table.setDbName(dbName); StorageDescriptor sd = new StorageDescriptor(); List<FieldSchema> fields = new ArrayList<FieldSchema>(); for (int i = 0; i < colNames.length; ++i) { fields.add(new FieldSchema(colNames[i], "string", "")); } sd.setCols(fields); sd.setInputFormat("org.apache.hadoop.mapred.TextInputFormat"); sd.setOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"); sd.setSerdeInfo(new SerDeInfo()); sd.getSerdeInfo().setParameters(new HashMap<String, String>()); sd.getSerdeInfo().getParameters().put(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, "1"); sd.setSortCols(new ArrayList<Order>()); table.setSd(sd); List<FieldSchema> partitions = new ArrayList<FieldSchema>(); for (int i = 0; i < partNames.length; ++i) { partitions.add(new FieldSchema(partNames[i], "string", "")); } table.setPartitionKeys(partitions); when(event.getTable()).thenReturn(table); glueSync.onCreateTable(event); verify(glueClient).createTable(requestCaptor.capture()); CreateTableRequest createTableRequest = requestCaptor.getValue(); assertThat(createTableRequest.getDatabaseName(), is(gluePrefix + dbName)); assertThat(createTableRequest.getTableInput().getName(), is(tableName)); assertThat(createTableRequest .getTableInput() .getPartitionKeys() .stream() .map(p -> p.getName()) .collect(Collectors.toList()), is(partitions.stream().map(p -> p.getName()).collect(Collectors.toList()))); assertThat(createTableRequest .getTableInput() .getStorageDescriptor() .getColumns() .stream() .map(p -> p.getName()) .collect(Collectors.toList()), is(fields.stream().map(p -> p.getName()).collect(Collectors.toList()))); }