src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public boolean revoke_privileges(PrivilegeBag privileges) throws MetaException, TException { if (privileges.isSetPrivileges() && !privileges.getPrivileges... | @Test public void revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.single... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GrantRevokePrivilegeResponse grant_revoke_privileges(GrantRevokePrivilegeRequest request) throws MetaException, TException { PrivilegeBag privilege... | @Test public void grant_revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public String get_delegation_token(String token_owner, String renewer_kerberos_principal_name) throws MetaException, TException { return getPrimaryClient(... | @Test public void get_delegation_token() throws TException { String expected = "expected"; when(primaryClient.get_delegation_token("owner", "kerberos_principal")).thenReturn(expected); String result = handler.get_delegation_token("owner", "kerberos_principal"); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public long renew_delegation_token(String token_str_form) throws MetaException, TException { return getPrimaryClient().renew_delegation_token(token_str_fo... | @Test public void renew_delegation_token() throws TException { long expected = 10L; when(primaryClient.renew_delegation_token("token")).thenReturn(expected); long result = handler.renew_delegation_token("token"); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void cancel_delegation_token(String token_str_form) throws MetaException, TException { getPrimaryClient().cancel_delegation_token(token_str_form); ... | @Test public void cancel_delegation_token() throws TException { handler.cancel_delegation_token("token"); verify(primaryClient).cancel_delegation_token("token"); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GetOpenTxnsResponse get_open_txns() throws TException { return getPrimaryClient().get_open_txns(); } FederatedHMSHandler(
MappingEventListene... | @Test public void get_open_txns() throws TException { GetOpenTxnsResponse expected = new GetOpenTxnsResponse(); when(primaryClient.get_open_txns()).thenReturn(expected); GetOpenTxnsResponse result = handler.get_open_txns(); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GetOpenTxnsInfoResponse get_open_txns_info() throws TException { return getPrimaryClient().get_open_txns_info(); } FederatedHMSHandler(
Mappi... | @Test public void get_open_txns_info() throws TException { GetOpenTxnsInfoResponse expected = new GetOpenTxnsInfoResponse(); when(primaryClient.get_open_txns_info()).thenReturn(expected); GetOpenTxnsInfoResponse result = handler.get_open_txns_info(); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException { return getPrimaryClient().open_txns(rqst); } FederatedHMSHandler(
Mapping... | @Test public void open_txns() throws TException { OpenTxnRequest request = new OpenTxnRequest(); OpenTxnsResponse expected = new OpenTxnsResponse(); when(primaryClient.open_txns(request)).thenReturn(expected); OpenTxnsResponse result = handler.open_txns(request); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void abort_txn(AbortTxnRequest rqst) throws NoSuchTxnException, TException { getPrimaryClient().abort_txn(rqst); } FederatedHMSHandler(
Mappi... | @Test public void abort_txn() throws TException { AbortTxnRequest request = new AbortTxnRequest(); handler.abort_txn(request); verify(primaryClient).abort_txn(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void commit_txn(CommitTxnRequest rqst) throws NoSuchTxnException, TxnAbortedException, TException { getPrimaryClient().commit_txn(rqst); } Federate... | @Test public void commit_txn() throws TException { CommitTxnRequest request = new CommitTxnRequest(); handler.commit_txn(request); verify(primaryClient).commit_txn(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public LockResponse lock(LockRequest rqst) throws NoSuchTxnException, TxnAbortedException, TException { DatabaseMapping mapping = databaseMappingService.p... | @Test public void lock() throws TException { LockComponent lockComponent = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, DB_P); LockRequest lockRequest = new LockRequest(Collections.singletonList(lockComponent), "user", "host"); LockRequest inboundRequest = new LockRequest(); LockResponse expected = new LockRespo... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public LockResponse check_lock(CheckLockRequest rqst) throws NoSuchTxnException, TxnAbortedException, NoSuchLockException, TException { return getPrimaryC... | @Test public void check_lock() throws TException { CheckLockRequest request = new CheckLockRequest(); LockResponse expected = new LockResponse(); when(primaryClient.check_lock(request)).thenReturn(expected); LockResponse result = handler.check_lock(request); assertThat(result, is(expected)); } |
CommonBeans { @Bean public HiveConf hiveConf(WaggleDanceConfiguration waggleDanceConfiguration) { Map<String, String> confProps = waggleDanceConfiguration.getConfigurationProperties(); final HiveConf hiveConf = new HiveConf(new Configuration(false), getClass()); if (confProps != null) { for (Map.Entry<String, String> e... | @Test public void hiveConf() { assertThat(hiveConf, is(notNullValue())); assertThat(hiveConf.get(CommonBeansTestContext.PROP_1), is(CommonBeansTestContext.VAL_1)); assertThat(hiveConf.get(CommonBeansTestContext.PROP_2), is(CommonBeansTestContext.VAL_2)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void unlock(UnlockRequest rqst) throws NoSuchLockException, TxnOpenException, TException { getPrimaryClient().unlock(rqst); } FederatedHMSHandler(
... | @Test public void unlock() throws TException { UnlockRequest request = new UnlockRequest(); handler.unlock(request); verify(primaryClient).unlock(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public ShowLocksResponse show_locks(ShowLocksRequest rqst) throws TException { return getPrimaryClient().show_locks(rqst); } FederatedHMSHandler(
Ma... | @Test public void show_locks() throws TException { ShowLocksRequest request = new ShowLocksRequest(); ShowLocksResponse expected = new ShowLocksResponse(); when(primaryClient.show_locks(request)).thenReturn(expected); ShowLocksResponse result = handler.show_locks(request); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void heartbeat(HeartbeatRequest ids) throws NoSuchLockException, NoSuchTxnException, TxnAbortedException, TException { getPrimaryClient().heartbeat... | @Test public void heartbeat() throws TException { HeartbeatRequest request = new HeartbeatRequest(); handler.heartbeat(request); verify(primaryClient).heartbeat(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public HeartbeatTxnRangeResponse heartbeat_txn_range(HeartbeatTxnRangeRequest txns) throws TException { return getPrimaryClient().heartbeat_txn_range(txns... | @Test public void heartbeat_txn_range() throws TException { HeartbeatTxnRangeRequest request = new HeartbeatTxnRangeRequest(); HeartbeatTxnRangeResponse expected = new HeartbeatTxnRangeResponse(); when(primaryClient.heartbeat_txn_range(request)).thenReturn(expected); HeartbeatTxnRangeResponse result = handler.heartbeat... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void compact(CompactionRequest rqst) throws TException { DatabaseMapping mapping = databaseMappingService.primaryDatabaseMapping(); mapping.checkWr... | @Test public void compact() throws TException { CompactionRequest request = new CompactionRequest(DB_P, "table", CompactionType.MAJOR); CompactionRequest inboundRequest = new CompactionRequest(); when(primaryMapping.transformInboundCompactionRequest(request)).thenReturn(inboundRequest); handler.compact(request); verify... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public ShowCompactResponse show_compact(ShowCompactRequest rqst) throws TException { return getPrimaryClient().show_compact(rqst); } FederatedHMSHandler(
... | @Test public void show_compact() throws TException { ShowCompactRequest request = new ShowCompactRequest(); ShowCompactResponse expected = new ShowCompactResponse(); when(primaryClient.show_compact(request)).thenReturn(expected); ShowCompactResponse result = handler.show_compact(request); assertThat(result, is(expected... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override public String getCpuProfile(int arg0) throws TException { return getPrimaryClient().getCpuProfile(arg0); } FederatedHMSHandler(
MappingEventListener databaseMappingService,
NotifyingFederationService notifyingFederationServ... | @Test public void getCpuProfile() throws TException { String expected = "expected"; when(primaryClient.getCpuProfile(10)).thenReturn(expected); String result = handler.getCpuProfile(10); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override public String getVersion() throws TException { return getPrimaryClient().getVersion(); } FederatedHMSHandler(
MappingEventListener databaseMappingService,
NotifyingFederationService notifyingFederationService); @Override vo... | @Test public void getVersion() throws TException { String expected = "version"; when(primaryClient.getVersion()).thenReturn(expected); String result = handler.getVersion(); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override public fb_status getStatus() { try { return getPrimaryClient().getStatus(); } catch (TException e) { LOG.error("Cannot getStatus() from client: ", e); return fb_status.DEAD; } } FederatedHMSHandler(
MappingEventListener databaseM... | @Test public void getStatus() throws TException { fb_status expected = fb_status.ALIVE; when(primaryClient.getStatus()).thenReturn(expected); fb_status result = handler.getStatus(); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override public Configuration getConf() { return conf; } FederatedHMSHandler(
MappingEventListener databaseMappingService,
NotifyingFederationService notifyingFederationService); @Override void close(); @Override void shutdown(); @O... | @Test public void getConf() { Configuration expected = new Configuration(); handler.setConf(expected); Configuration result = handler.getConf(); assertThat(result, is(expected)); } |
YamlStorageConfiguration { public boolean isOverwriteConfigOnShutdown() { return overwriteConfigOnShutdown; } void setOverwriteConfigOnShutdown(boolean overwriteConfigOnShutdown); boolean isOverwriteConfigOnShutdown(); } | @Test public void defaultOverwriteConfigOnShutdown() { assertThat(configuration.isOverwriteConfigOnShutdown(), is(true)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void abort_txns(AbortTxnsRequest rqst) throws NoSuchTxnException, TException { getPrimaryClient().abort_txns(rqst); } FederatedHMSHandler(
Ma... | @Test public void abort_txns() throws TException { AbortTxnsRequest request = new AbortTxnsRequest(); handler.abort_txns(request); verify(primaryClient).abort_txns(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void add_dynamic_partitions(AddDynamicPartitions rqst) throws NoSuchTxnException, TxnAbortedException, TException { DatabaseMapping mapping = check... | @Test public void add_dynamic_partitions() throws TException { AddDynamicPartitions request = new AddDynamicPartitions(1, DB_P, "table", Collections.emptyList()); AddDynamicPartitions inboundRequest = new AddDynamicPartitions(); when(primaryMapping.transformInboundAddDynamicPartitions(request)).thenReturn(inboundReques... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void add_foreign_key(AddForeignKeyRequest req) throws NoSuchObjectException, MetaException, TException { getPrimaryClient().add_foreign_key(req); }... | @Test public void add_foreign_key() throws TException { AddForeignKeyRequest request = new AddForeignKeyRequest(); handler.add_foreign_key(request); verify(primaryClient).add_foreign_key(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public int add_master_key(String key) throws MetaException, TException { return getPrimaryClient().add_master_key(key); } FederatedHMSHandler(
Mappi... | @Test public void add_master_key() throws TException { int expected = 10; when(primaryClient.add_master_key("key")).thenReturn(expected); int result = handler.add_master_key("key"); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void add_primary_key(AddPrimaryKeyRequest req) throws NoSuchObjectException, MetaException, TException { getPrimaryClient().add_primary_key(req); }... | @Test public void add_primary_key() throws TException { AddPrimaryKeyRequest request = new AddPrimaryKeyRequest(); handler.add_primary_key(request); verify(primaryClient).add_primary_key(request); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public boolean add_token(String token_identifier, String delegation_token) throws TException { return getPrimaryClient().add_token(token_identifier, deleg... | @Test public void add_token() throws TException { when(primaryClient.add_token("identifier", "delegation")).thenReturn(true); boolean result = handler.add_token("identifier", "delegation"); assertThat(result, is(true)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_partitions_with_environment_context( String db_name, String tbl_name, List<Partition> new_parts, EnvironmentContext environment_context)... | @Test public void alter_partitions_with_environment_context() throws TException { EnvironmentContext environmentContext = new EnvironmentContext(); handler.alter_partitions_with_environment_context(DB_P, "table", Collections.emptyList(), environmentContext); verify(primaryMapping).checkWritePermissions(DB_P); verify(pr... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_table_with_cascade(String dbname, String tbl_name, Table new_tbl, boolean cascade) throws InvalidOperationException, MetaException, TExc... | @Test public void alter_table_with_cascade() throws TException { Table table = new Table(); handler.alter_table_with_cascade(DB_P, "table", table, true); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).alter_table_with_cascade(DB_P, "table", table, true); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public CacheFileMetadataResult cache_file_metadata(CacheFileMetadataRequest req) throws TException { DatabaseMapping mapping = databaseMappingService.prim... | @Test public void cache_file_metadata() throws TException { CacheFileMetadataRequest request = new CacheFileMetadataRequest(DB_P, "table"); CacheFileMetadataRequest inboundRequest = new CacheFileMetadataRequest(); CacheFileMetadataResult expected = new CacheFileMetadataResult(); when(primaryMapping.transformInboundCach... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public ClearFileMetadataResult clear_file_metadata(ClearFileMetadataRequest req) throws TException { return getPrimaryClient().clear_file_metadata(req); }... | @Test public void clear_file_metadata() throws TException { ClearFileMetadataRequest request = new ClearFileMetadataRequest(); ClearFileMetadataResult expected = new ClearFileMetadataResult(); when(primaryClient.clear_file_metadata(request)).thenReturn(expected); ClearFileMetadataResult result = handler.clear_file_meta... |
YamlStorageConfiguration { public void setOverwriteConfigOnShutdown(boolean overwriteConfigOnShutdown) { this.overwriteConfigOnShutdown = overwriteConfigOnShutdown; } void setOverwriteConfigOnShutdown(boolean overwriteConfigOnShutdown); boolean isOverwriteConfigOnShutdown(); } | @Test public void setOverwriteConfigOnShutdown() { configuration.setOverwriteConfigOnShutdown(false); assertThat(configuration.isOverwriteConfigOnShutdown(), is(false)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void create_table_with_constraints(Table tbl, List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys) throws AlreadyExistsException, Inva... | @Test public void create_table_with_constraints() throws TException { Table table = new Table(); table.setDbName(DB_P); Table inboundTable = new Table(); List<SQLPrimaryKey> primaryKeys = Collections.emptyList(); List<SQLForeignKey> foreignKeys = Collections.emptyList(); when(primaryMapping.transformInboundTable(table)... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void drop_constraint(DropConstraintRequest req) throws NoSuchObjectException, MetaException, TException { DatabaseMapping mapping = checkWritePermi... | @Test public void drop_constraint() throws TException { DropConstraintRequest request = new DropConstraintRequest(DB_P, "table", "constraint"); DropConstraintRequest inboundRequest = new DropConstraintRequest(); when(primaryMapping.transformInboundDropConstraintRequest(request)).thenReturn(inboundRequest); handler.drop... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<Partition> exchange_partitions( Map<String, String> partitionSpecs, String source_db, String source_table_name, String dest_db, String dest_ta... | @Test public void exchange_partitions() throws TException { Map<String, String> partitionSpecs = new HashMap<>(); List<Partition> partitions = Collections.emptyList(); List<Partition> expected = Collections.emptyList(); when(primaryMapping.transformInboundDatabaseName("dest_db")).thenReturn("dest_db"); when(primaryMapp... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public FireEventResponse fire_listener_event(FireEventRequest rqst) throws TException { DatabaseMapping mapping = databaseMappingService.databaseMapping(r... | @Test public void fire_listener_event() throws TException { FireEventRequest request = new FireEventRequest(); request.setDbName(DB_P); FireEventRequest inboundRequest = new FireEventRequest(); FireEventResponse expected = new FireEventResponse(); when(primaryMapping.transformInboundFireEventRequest(request)).thenRetur... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<String> get_all_token_identifiers() throws TException { return getPrimaryClient().get_all_token_identifiers(); } FederatedHMSHandler(
Ma... | @Test public void get_all_token_identifiers() throws TException { List<String> expected = Arrays.asList("token1", "token2"); when(primaryClient.get_all_token_identifiers()).thenReturn(expected); List<String> result = handler.get_all_token_identifiers(); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public CurrentNotificationEventId get_current_notificationEventId() throws TException { return getPrimaryClient().get_current_notificationEventId(); } Fed... | @Test public void get_current_notificationEventId() throws TException { handler.get_current_notificationEventId(); verify(primaryClient).get_current_notificationEventId(); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<FieldSchema> get_fields_with_environment_context( String db_name, String table_name, EnvironmentContext environment_context) throws MetaExcept... | @Test public void get_fields_with_environment_context() throws TException { EnvironmentContext context = new EnvironmentContext(); List<FieldSchema> expected = Arrays.asList(new FieldSchema("name1", "type1", ""), new FieldSchema("name2", "type2", "")); when(primaryClient.get_fields_with_environment_context(DB_P, "table... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GetFileMetadataResult get_file_metadata(GetFileMetadataRequest req) throws TException { return getPrimaryClient().get_file_metadata(req); } Federat... | @Test public void get_file_metadata() throws TException { GetFileMetadataRequest request = new GetFileMetadataRequest(); GetFileMetadataResult expected = new GetFileMetadataResult(); when(primaryClient.get_file_metadata(request)).thenReturn(expected); GetFileMetadataResult result = handler.get_file_metadata(request); a... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GetFileMetadataByExprResult get_file_metadata_by_expr(GetFileMetadataByExprRequest req) throws TException { return getPrimaryClient().get_file_meta... | @Test public void get_file_metadata_by_expr() throws TException { GetFileMetadataByExprRequest request = new GetFileMetadataByExprRequest(); GetFileMetadataByExprResult expected = new GetFileMetadataByExprResult(); when(primaryClient.get_file_metadata_by_expr(request)).thenReturn(expected); GetFileMetadataByExprResult ... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<String> get_master_keys() throws TException { return getPrimaryClient().get_master_keys(); } FederatedHMSHandler(
MappingEventListener d... | @Test public void get_master_keys() throws TException { List<String> expected = Arrays.asList("key1", "key2"); when(primaryClient.get_master_keys()).thenReturn(expected); List<String> result = handler.get_master_keys(); assertThat(result, is(expected)); } |
GraphiteConfiguration { public void setPort(int port) { this.port = port; } @PostConstruct void init(); boolean isEnabled(); int getPort(); void setPort(int port); String getHost(); void setHost(String host); String getPrefix(); void setPrefix(String prefix); long getPollInterval(); void setPollInterval(long pollInter... | @Test public void zeroPort() { graphiteConfiguration.setPort(0); Set<ConstraintViolation<GraphiteConfiguration>> violations = validator.validate(graphiteConfiguration); assertThat(violations.size(), is(1)); }
@Test public void negativePort() { graphiteConfiguration.setPort(-1); Set<ConstraintViolation<GraphiteConfigura... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public NotificationEventResponse get_next_notification(NotificationEventRequest rqst) throws TException { return getPrimaryClient().get_next_notification(... | @Test public void get_next_notification() throws TException { NotificationEventRequest request = new NotificationEventRequest(); NotificationEventResponse expected = new NotificationEventResponse(); when(primaryClient.get_next_notification(request)).thenReturn(expected); NotificationEventResponse result = handler.get_n... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public int get_num_partitions_by_filter(String db_name, String tbl_name, String filter) throws MetaException, NoSuchObjectException, TException { Database... | @Test public void get_num_partitions_by_filter() throws TException { int expected = 10; when(primaryClient.get_num_partitions_by_filter(DB_P, "table", "filter")).thenReturn(expected); int result = handler.get_num_partitions_by_filter(DB_P, "table", "filter"); assertThat(result, is(expected)); } |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public PrimaryKeysResponse get_primary_keys(PrimaryKeysRequest request) throws MetaException, NoSuchObjectException, TException { DatabaseMapping mapping ... | @Test public void get_primary_keys() throws TException { PrimaryKeysRequest request = new PrimaryKeysRequest(DB_P, "table"); PrimaryKeysRequest inboundRequest = new PrimaryKeysRequest(); PrimaryKeysResponse response = new PrimaryKeysResponse(); PrimaryKeysResponse expected = new PrimaryKeysResponse(); when(primaryMappi... |
FederatedHMSHandler extends FacebookBase implements CloseableIHMSHandler { @Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public PartitionValuesResponse get_partition_values(PartitionValuesRequest req) throws MetaException, NoSuchObjectException, TException { DatabaseMapping ... | @Test public void get_partition_values() throws TException { PartitionValuesRequest request = new PartitionValuesRequest(DB_P, "table", Collections.singletonList(new FieldSchema())); List<PartitionValuesRow> partitionValues = Collections.singletonList(new PartitionValuesRow()); PartitionValuesResponse response = new Pa... |
TSetIpAddressProcessorFactory extends TProcessorFactory { @Override public TProcessor getProcessor(TTransport transport) { try { if (transport instanceof TSocket) { Socket socket = ((TSocket) transport).getSocket(); log.debug("Received a connection from ip: {}", socket.getInetAddress().getHostAddress()); } CloseableIHM... | @Test public void correctType() throws Exception { TProcessor processor = factory.getProcessor(transport); assertThat(TSetIpAddressProcessor.class.isAssignableFrom(processor.getClass()), is(true)); }
@Test public void connectionIsMonitored() throws Exception { factory.getProcessor(transport); ArgumentCaptor<TTransport>... |
ExceptionWrappingHMSHandler implements InvocationHandler { public static IHMSHandler newProxyInstance(IHMSHandler baseHandler) { return (IHMSHandler) Proxy.newProxyInstance(ExceptionWrappingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, new ExceptionWrappingHMSHandler(baseHandler)); } ExceptionWr... | @Test public void get_databaseNoExceptions() throws Exception { IHMSHandler handler = ExceptionWrappingHMSHandler.newProxyInstance(baseHandler); handler.get_database("bdp"); verify(baseHandler).get_database("bdp"); }
@Test public void get_databaseWaggleDanceServerException() throws Exception { expectedException.expect(... |
FederatedHMSHandlerFactory { public CloseableIHMSHandler create() { MappingEventListener service = createDatabaseMappingService(); MonitoredDatabaseMappingService monitoredService = new MonitoredDatabaseMappingService(service); CloseableIHMSHandler baseHandler = new FederatedHMSHandler(monitoredService, notifyingFedera... | @Test public void typical() throws Exception { when(waggleDanceConfiguration.getDatabaseResolution()).thenReturn(DatabaseResolution.MANUAL); CloseableIHMSHandler handler = factory.create(); assertThat(handler, is(instanceOf(FederatedHMSHandler.class))); }
@Test public void prefixedDatabase() throws Exception { when(wag... |
GraphiteConfiguration { public void setPollInterval(long pollInterval) { this.pollInterval = pollInterval; } @PostConstruct void init(); boolean isEnabled(); int getPort(); void setPort(int port); String getHost(); void setHost(String host); String getPrefix(); void setPrefix(String prefix); long getPollInterval(); vo... | @Test public void zeroPollInterval() { graphiteConfiguration.setPollInterval(0); Set<ConstraintViolation<GraphiteConfiguration>> violations = validator.validate(graphiteConfiguration); assertThat(violations.size(), is(1)); }
@Test public void negativePollInterval() { graphiteConfiguration.setPollInterval(-1); Set<Const... |
GraphiteConfiguration { public void setPollIntervalTimeUnit(TimeUnit pollIntervalTimeUnit) { this.pollIntervalTimeUnit = pollIntervalTimeUnit; } @PostConstruct void init(); boolean isEnabled(); int getPort(); void setPort(int port); String getHost(); void setHost(String host); String getPrefix(); void setPrefix(String... | @Test public void nullPollIntervalTimeUnit() { graphiteConfiguration.setPollIntervalTimeUnit(null); Set<ConstraintViolation<GraphiteConfiguration>> violations = validator.validate(graphiteConfiguration); assertThat(violations.size(), is(1)); } |
AbstractMetaStore { public void setRemoteMetaStoreUris(String remoteMetaStoreUris) { this.remoteMetaStoreUris = remoteMetaStoreUris; } AbstractMetaStore(); AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType); AbstractMetaStore(
String name,
String remoteMetaStor... | @Test public void nullRemoteMetaStoreUris() { metaStore.setRemoteMetaStoreUris(null); Set<ConstraintViolation<T>> violations = validator.validate(metaStore); assertThat(violations.size(), is(1)); }
@Test public void emptyRemoteMetaStoreUris() { metaStore.setRemoteMetaStoreUris(" "); Set<ConstraintViolation<T>> violatio... |
WaggleDanceConfiguration { public void setPort(Integer port) { this.port = port; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnectConnectionDelay(int disconnectConnectionDelay); TimeUnit getDisconnectTimeUnit()... | @Test public void nullPort() { waggleDanceConfiguration.setPort(null); Set<ConstraintViolation<WaggleDanceConfiguration>> violations = validator.validate(waggleDanceConfiguration); assertThat(violations.size(), is(1)); }
@Test public void zeroPort() { waggleDanceConfiguration.setPort(0); Set<ConstraintViolation<WaggleD... |
WaggleDanceConfiguration { public void setDisconnectConnectionDelay(int disconnectConnectionDelay) { this.disconnectConnectionDelay = disconnectConnectionDelay; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnect... | @Test public void zeroDisconnectConnectionDelay() { waggleDanceConfiguration.setDisconnectConnectionDelay(0); Set<ConstraintViolation<WaggleDanceConfiguration>> violations = validator.validate(waggleDanceConfiguration); assertThat(violations.size(), is(1)); }
@Test public void negativeDisconnectConnectionDelay() { wagg... |
WaggleDanceConfiguration { public void setDisconnectTimeUnit(TimeUnit disconnectTimeUnit) { this.disconnectTimeUnit = disconnectTimeUnit; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnectConnectionDelay(int dis... | @Test public void nullDisconnectTimeUnit() { waggleDanceConfiguration.setDisconnectTimeUnit(null); Set<ConstraintViolation<WaggleDanceConfiguration>> violations = validator.validate(waggleDanceConfiguration); assertThat(violations.size(), is(1)); } |
WaggleDanceConfiguration { public void setConfigurationProperties(Map<String, String> configurationProperties) { this.configurationProperties = configurationProperties; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDi... | @Test public void nullConfigurationProperties() { waggleDanceConfiguration.setConfigurationProperties(null); Set<ConstraintViolation<WaggleDanceConfiguration>> violations = validator.validate(waggleDanceConfiguration); assertThat(violations.size(), is(0)); }
@Test public void emptyConfigurationProperties() { waggleDanc... |
WaggleDanceConfiguration { public void setDatabaseResolution(DatabaseResolution databaseResolution) { this.databaseResolution = databaseResolution; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnectConnectionDel... | @Test public void nullDatabaseResolution() { waggleDanceConfiguration.setDatabaseResolution(null); Set<ConstraintViolation<WaggleDanceConfiguration>> violations = validator.validate(waggleDanceConfiguration); assertThat(violations.size(), is(1)); } |
WaggleDanceConfiguration { public int getStatusPollingDelay() { return statusPollingDelay; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnectConnectionDelay(int disconnectConnectionDelay); TimeUnit getDisconnect... | @Test public void setterGetterStatusPollingDelayDefault() { assertThat(waggleDanceConfiguration.getStatusPollingDelay(), is(5)); } |
WaggleDanceConfiguration { public TimeUnit getStatusPollingDelayTimeUnit() { return statusPollingDelayTimeUnit; } Integer getPort(); void setPort(Integer port); boolean isVerbose(); void setVerbose(boolean verbose); int getDisconnectConnectionDelay(); void setDisconnectConnectionDelay(int disconnectConnectionDelay); T... | @Test public void setterGetterStatusPollingDelayTimeUnitDefault() { assertThat(waggleDanceConfiguration.getStatusPollingDelayTimeUnit(), is(TimeUnit.MINUTES)); } |
CloseableThriftHiveMetastoreIfaceClientFactory { public CloseableThriftHiveMetastoreIface newInstance(AbstractMetaStore metaStore) { String uris = MetaStoreUriNormaliser.normaliseMetaStoreUris(metaStore.getRemoteMetaStoreUris()); String name = metaStore.getName().toLowerCase(Locale.ROOT); int connectionTimeout = Math.m... | @Test public void defaultFactory() { ArgumentCaptor<HiveConf> hiveConfCaptor = ArgumentCaptor.forClass(HiveConf.class); factory.newInstance(newFederatedInstance("fed1", THRIFT_URI)); verify(defaultMetaStoreClientFactory).newInstance(hiveConfCaptor.capture(), eq( "waggledance-fed1"), eq(3), eq(2000)); verifyZeroInteract... |
HiveCompatibleThriftHiveMetastoreIfaceFactory { public CloseableThriftHiveMetastoreIface newInstance(ThriftHiveMetastore.Client delegate) { HiveThriftMetaStoreIfaceCompatibility compatibility = new HiveThriftMetaStoreIfaceCompatibility1xx(delegate); return newInstance(delegate, compatibility); } CloseableThriftHiveMet... | @Test public void get_table_req() throws Exception { CloseableThriftHiveMetastoreIface thriftHiveMetastoreIface = factory.newInstance(delegate); GetTableRequest tableRequest = new GetTableRequest(DB_NAME, TABLE_NAME); when(delegate.get_table_req(tableRequest)).thenThrow(new TApplicationException("Error")); when(delegat... |
AbstractMetaStore { public void setMetastoreTunnel(MetastoreTunnel metastoreTunnel) { this.metastoreTunnel = metastoreTunnel; } AbstractMetaStore(); AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType); AbstractMetaStore(
String name,
String remoteMetaStoreUris,
... | @Test public void validMetastoreTunnel() { metaStore.setMetastoreTunnel(newMetastoreTunnel()); Set<ConstraintViolation<T>> violations = validator.validate(metaStore); assertThat(violations.size(), is(0)); }
@Test public void invalidMetastoreTunnel() { MetastoreTunnel metastoreTunnel = newMetastoreTunnel(); metastoreTun... |
TunnelingMetaStoreClientFactory { public CloseableThriftHiveMetastoreIface newInstance( String uris, MetastoreTunnel metastoreTunnel, String name, int reconnectionRetries, int connectionTimeout) { String uri = uris; String[] urisSplit = uri.split(","); if (urisSplit.length > 1) { uri = urisSplit[0]; LOG.debug("Can't su... | @Test public void newInstance() { tunnelingMetaStoreClientFactory.newInstance(METASTORE_URI, metastoreTunnel, NAME, RECONNECTION_RETRIES, CONNECTION_TIMEOUT); verify(tunnelableFactory) .wrap(tunnelableSupplierCaptor.capture(), eq(tunnelingMetaStoreClientFactory.METHOD_CHECKER), eq(metastoreTunnel.getLocalhost()), anyIn... |
TunnelableFactorySupplier { public TunnelableFactory<CloseableThriftHiveMetastoreIface> get(MetastoreTunnel metastoreTunnel) { return new TunnelableFactory<>(buildSshSettings(metastoreTunnel)); } TunnelableFactory<CloseableThriftHiveMetastoreIface> get(MetastoreTunnel metastoreTunnel); } | @Test public void get() { TunnelableFactory<CloseableThriftHiveMetastoreIface> tunnelableFactory = supplier.get(metastoreTunnel); assertNotNull(tunnelableFactory); } |
TunnelableFactorySupplier { @VisibleForTesting SshSettings buildSshSettings(MetastoreTunnel metastoreTunnel) { return SshSettings .builder() .withSshPort(metastoreTunnel.getPort()) .withSessionTimeout(metastoreTunnel.getTimeout()) .withRoute(metastoreTunnel.getRoute()) .withKnownHosts(metastoreTunnel.getKnownHosts()) .... | @Test public void buildSshSettings() { SshSettings sshSettings = supplier.buildSshSettings(metastoreTunnel); assertThat(sshSettings.getRoute(), is(TUNNEL_ROUTE)); assertThat(sshSettings.getPrivateKeys(), is(Lists.newArrayList(TUNNEL_PRIVATE_KEY))); assertThat(sshSettings.getKnownHosts(), is(TUNNEL_KNOWN_HOSTS)); assert... |
HiveMetaStoreClientSupplier implements TunnelableSupplier<CloseableThriftHiveMetastoreIface> { @Override public CloseableThriftHiveMetastoreIface get() { return factory.newInstance(hiveConf, name, reconnectionRetries, connectionTimeout); } HiveMetaStoreClientSupplier(MetaStoreClientFactory factory, HiveConf hiveConf, S... | @Test public void getMetaStoreClientFactoryInstance() { String name = "test"; int reconnectionRetries = 10; int connectionTimeout = 10; HiveMetaStoreClientSupplier supplier = new HiveMetaStoreClientSupplier(factory, hiveConf, name, reconnectionRetries, connectionTimeout); supplier.get(); verify(factory).newInstance(hiv... |
LocalHiveConfFactory { HiveConf newInstance(String localHost, int localPort, HiveConf hiveConf) { HiveConf localHiveConf = new HiveConf(hiveConf); String proxyMetaStoreUris = "thrift: localHiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, proxyMetaStoreUris); return localHiveConf; } } | @Test public void getCorrectHiveConf() { String localHost = "localHost"; int localPort = 10; String expectedUri = "thrift: HiveConf hiveConf = new HiveConf(); HiveConf conf = new LocalHiveConfFactory().newInstance(localHost, localPort, hiveConf); assertThat(conf.getVar(HiveConf.ConfVars.METASTOREURIS), is(expectedUri))... |
DefaultMetaStoreClientFactory implements MetaStoreClientFactory { @Override public CloseableThriftHiveMetastoreIface newInstance( HiveConf hiveConf, String name, int reconnectionRetries, int connectionTimeout) { return newInstance(name, reconnectionRetries, new ThriftMetastoreClientManager(hiveConf, new HiveCompatibleT... | @Test public void isOpen() { when(base.isOpen()).thenReturn(true); CloseableThriftHiveMetastoreIface iface = factory.newInstance("name", RECONNECTION_RETRIES, base); boolean result = iface.isOpen(); assertThat(result, is(true)); verify(base, never()).reconnect(); }
@Test public void isOpenWithReconnection() { when(base... |
ThriftMetastoreClientManager implements Closeable { void open() { if (isConnected) { return; } TException te = null; boolean useSasl = conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL); boolean useFramedTransport = conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_FRAMED_TRANSPORT); boolean useCompactProtocol = conf.getB... | @Test(expected = RuntimeException.class) public void openSlowConnection() { client = new ThriftMetastoreClientManager(hiveConf, hiveCompatibleThriftHiveMetastoreIfaceFactory, 1); client.open(); } |
MetaStoreMappingFactoryImpl implements MetaStoreMappingFactory { @SuppressWarnings("resource") @Override public MetaStoreMapping newInstance(AbstractMetaStore metaStore) { LOG .info("Mapping databases with name '{}' to metastore: {}", metaStore.getName(), metaStore.getRemoteMetaStoreUris()); MetaStoreMapping metaStoreM... | @Test public void typicalPrefixed() { when(waggleDanceConfiguration.getDatabaseResolution()).thenReturn(DatabaseResolution.PREFIXED); AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri()); MetaStoreMapping mapping = factory.newInstance(federatedMetaStore); assertThat(mappi... |
AbstractMetaStore { public void setName(String name) { this.name = name; } AbstractMetaStore(); AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType); AbstractMetaStore(
String name,
String remoteMetaStoreUris,
AccessControlType accessControlType,
List... | @Test public void nullName() { metaStore.setName(null); Set<ConstraintViolation<T>> violations = validator.validate(metaStore); assertThat(violations.size(), is(1)); }
@Test public void emptyName() { metaStore.setName(" "); Set<ConstraintViolation<T>> violations = validator.validate(metaStore); assertThat(violations.si... |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public MetaStoreMapping checkWritePermissions(String databaseName) { return metaStoreMapping.checkWritePermissions(databaseName); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databa... | @Test public void checkWritePermissions() throws Exception { decorator.checkWritePermissions("db"); verify(metaStoreMapping).checkWritePermissions("db"); } |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public void close() throws IOException { metaStoreMapping.close(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> transformOutboundDatabaseNameMu... | @Test public void close() throws Exception { decorator.close(); verify(metaStoreMapping).close(); } |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public void createDatabase(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, TException { metaStoreMapping.createDatabase(database); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String t... | @Test public void createDatabase() throws Exception { Database database = new Database(); decorator.createDatabase(database); verify(metaStoreMapping).createDatabase(database); } |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public Iface getClient() { return metaStoreMapping.getClient(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> transformOutboundDatabaseNameMulti... | @Test public void getClient() throws Exception { when(metaStoreMapping.getClient()).thenReturn(client); Iface result = decorator.getClient(); assertThat(result, is(client)); } |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public String getDatabasePrefix() { return metaStoreMapping.getDatabasePrefix(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> transformOutbound... | @Test public void getDatabasePrefix() throws Exception { when(metaStoreMapping.getDatabasePrefix()).thenReturn("pre"); String result = decorator.getDatabasePrefix(); assertThat(result, is("pre")); } |
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public long getLatency() { return metaStoreMapping.getLatency(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> transformOutboundDatabaseNameMult... | @Test public void getLatency() throws Exception { when(metaStoreMapping.getLatency()).thenReturn(1L); long result = decorator.getLatency(); assertThat(result, is(1L)); } |
SimpleXPathBasedCheck extends SonarXmlCheck { public XPathExpression getXPathExpression(String expression) { try { return xpath.compile(expression); } catch (XPathExpressionException e) { throw new IllegalStateException(String.format("[%s] Fail to compile XPath expression '%s'.", ruleKey(), expression), e); } } XPathE... | @Test(expected = IllegalStateException.class) public void test_invalid_xpath_compilation_throws_exception() throws Exception { new SimpleXPathBasedCheck() { XPathExpression failing = getXPathExpression("boolean(a"); @Override public void scanFile(XmlFile file) { } }; } |
BuiltInQualityProfileJsonLoader { public static void load(NewBuiltInQualityProfile profile, String repositoryKey, String jsonProfilePath) { Set<String> activeKeys = loadActiveKeysFromJsonProfile(jsonProfilePath); for (String activeKey : activeKeys) { profile.activateRule(repositoryKey, activeKey); } } private BuiltInQ... | @Test public void fails_when_activating_rules_more_than_once() { NewBuiltInQualityProfile newProfile = testContext.createBuiltInQualityProfile(PROFILE_NAME, LANGUAGE); BuiltInQualityProfileJsonLoader.load(newProfile, REPOSITORY_KEY, PROFILE_PATH); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("The... |
RuleMetadataLoader { public void addRulesByAnnotatedClass(NewRepository repository, List<Class<?>> ruleClasses) { for (Class<?> ruleClass : ruleClasses) { addRuleByAnnotatedClass(repository, ruleClass); } } RuleMetadataLoader(String resourceFolder); RuleMetadataLoader(String resourceFolder, String defaultProfilePath);... | @Test public void load_rule_S100() throws Exception { @Rule(key = "S100") class TestRule { } ruleMetadataLoader.addRulesByAnnotatedClass(newRepository, Collections.singletonList(TestRule.class)); newRepository.done(); RulesDefinition.Repository repository = context.repository(RULE_REPOSITORY_KEY); RulesDefinition.Rule ... |
RuleMetadataLoader { public void addRulesByRuleKey(NewRepository repository, List<String> ruleKeys) { for (String ruleKey : ruleKeys) { addRuleByRuleKey(repository, ruleKey); } } RuleMetadataLoader(String resourceFolder); RuleMetadataLoader(String resourceFolder, String defaultProfilePath); private RuleMetadataLoader... | @Test public void load_rules_key_based() throws Exception { ruleMetadataLoader.addRulesByRuleKey(newRepository, Arrays.asList("S110", "S100")); newRepository.done(); RulesDefinition.Repository repository = context.repository(RULE_REPOSITORY_KEY); RulesDefinition.Rule ruleS110 = repository.rule("S110"); assertThat(ruleS... |
SafetyFactory { @Deprecated public static XMLInputFactory createXMLInputFactory() { return SafeStaxParserFactory.createXMLInputFactory(); } private SafetyFactory(); @Deprecated static XMLInputFactory createXMLInputFactory(); @Deprecated static DocumentBuilder createDocumentBuilder(boolean namespaceAware); } | @Test public void test_createXMLInputFactory() { assertThat(SafetyFactory.createXMLInputFactory()).isNotNull(); } |
RuleMetadataLoader { static String[] getStringArray(Map<String, Object> map, String propertyName) { Object propertyValue = map.get(propertyName); if (!(propertyValue instanceof List)) { throw new IllegalStateException(String.format(INVALID_PROPERTY_MESSAGE, propertyName)); } return ((List<String>) propertyValue).toArra... | @Test public void getStringArray() throws Exception { Map<String, Object> map = Collections.singletonMap("key", Arrays.asList("x", "y")); assertThat(RuleMetadataLoader.getStringArray(map, "key")).containsExactly("x", "y"); }
@Test(expected = IllegalStateException.class) public void getStringArray_with_invalid_type() th... |
SafetyFactory { @Deprecated public static DocumentBuilder createDocumentBuilder(boolean namespaceAware) { return SafeDomParserFactory.createDocumentBuilder(namespaceAware); } private SafetyFactory(); @Deprecated static XMLInputFactory createXMLInputFactory(); @Deprecated static DocumentBuilder createDocumentBuilder(bo... | @Test public void test_createDocumentBuilder() { assertThat(SafetyFactory.createDocumentBuilder(true)).isNotNull(); assertThat(SafetyFactory.createDocumentBuilder(false)).isNotNull(); } |
Resources { static String toString(String path, Charset charset) throws IOException { try (InputStream input = Resources.class.getClassLoader().getResourceAsStream(path)) { if (input == null) { throw new IOException("Resource not found in the classpath: " + path); } ByteArrayOutputStream out = new ByteArrayOutputStream... | @Test public void read_resource() throws Exception { assertThat(Resources.toString("org/sonarsource/analyzer/commons/ResourcesTest.txt", UTF_8)).isEqualTo("hello\n"); }
@Test(expected = IOException.class) public void read_invalid_resource() throws Exception { Resources.toString("invalid/path.txt", UTF_8); } |
ExternalReportProvider { public static List<File> getReportFiles(SensorContext context, String externalReportsProperty) { boolean externalIssuesSupported = context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2)); String[] reportPaths = context.config().getStringArray(externalReportsProperty); if (repor... | @Test public void test_return_empty_when_no_value() throws Exception { SensorContextTester context = SensorContextTester.create(new File(".")); List<File> reportFiles = ExternalReportProvider.getReportFiles(context, EXTERNAL_REPORTS_PROPERTY); assertThat(reportFiles).isEmpty(); assertThat(logTester.logs()).isEmpty(); }... |
ContainsDetector extends Detector { @Override public int scan(String line) { String lineWithoutWhitespaces = StringUtils.deleteWhitespace(line); int matchers = 0; for (String str : strs) { matchers += StringUtils.countMatches(lineWithoutWhitespaces, str); } return matchers; } ContainsDetector(double probability, String... | @Test public void scan() { ContainsDetector detector = new ContainsDetector(0.3, "++", "for("); assertThat(detector.scan("for (int i =0; i++; i<4) {")).isEqualTo(2); assertThat(detector.scan("String name;")).isZero(); } |
EndWithDetector extends Detector { @Override public int scan(String line) { for (int index = line.length() - 1; index >= 0; index--) { char character = line.charAt(index); for (char endOfLine : endOfLines) { if (character == endOfLine) { return 1; } } if (!Character.isWhitespace(character) && character != '*' && charac... | @Test public void scan() { EndWithDetector detector = new EndWithDetector(0.3, '}'); assertThat(detector.scan(" return true; }")).isOne(); assertThat(detector.scan("} catch(NullPointerException e) {")).isZero(); assertThat(detector.scan("} ")).isOne(); assertThat(detector.scan("}*")).isOne(); assertThat(detector.scan("... |
CamelCaseDetector extends Detector { @Override public int scan(String line) { char previousChar = ' '; char indexChar; for (int i = 0; i < line.length(); i++) { indexChar = line.charAt(i); if (isLowerCaseThenUpperCase(previousChar, indexChar)) { return 1; } previousChar = indexChar; } return 0; } CamelCaseDetector(doub... | @Test public void scan() { CamelCaseDetector detector = new CamelCaseDetector(0.3); assertThat(detector.scan("isDog() or isCat()")).isOne(); assertThat(detector.scan("String name;")).isZero(); } |
XmlFile { @CheckForNull public static Node nodeAttribute(Node node, String attribute) { NamedNodeMap attributes = node.getAttributes(); if (attributes == null) { return null; } return attributes.getNamedItem(attribute); } private XmlFile(InputFile inputFile); private XmlFile(String str); static XmlFile create(InputFi... | @Test public void testNodeAttribute() throws Exception { XmlFile xmlFile = XmlFile.create( "<a attr='foo'>\n" + " <!-- comment -->\n" + " <b>world</b>\n" + "</a>"); Node aNode = xmlFile.getDocument().getFirstChild(); assertThat(XmlFile.nodeAttribute(aNode, "attr")).isNotNull(); assertThat(XmlFile.nodeAttribute(aNode, "... |
KeywordsDetector extends Detector { @Override public int scan(String line) { int matchers = 0; if (toUpperCase) { line = line.toUpperCase(Locale.getDefault()); } StringTokenizer tokenizer = new StringTokenizer(line, " \t(),{}"); while (tokenizer.hasMoreTokens()) { String word = tokenizer.nextToken(); if (keywords.conta... | @Test public void scan() { KeywordsDetector detector = new KeywordsDetector(0.3, "public", "static"); assertThat(detector.scan("public static void main")).isEqualTo(2); assertThat(detector.scan("private(static} String name;")).isOne(); assertThat(detector.scan("publicstatic")).isZero(); assertThat(detector.scan("i++;")... |
CodeRecognizer { public final boolean isLineOfCode(String line) { return recognition(line) - threshold > 0; } CodeRecognizer(double threshold, LanguageFootprint language); final double recognition(String line); final List<String> extractCodeLines(List<String> lines); final boolean isLineOfCode(String line); } | @Test public void isLineOfCode() { CodeRecognizer cr = new CodeRecognizer(0.8, new FakeFootprint()); assertThat(cr.isLineOfCode("}")).isTrue(); assertThat(cr.isLineOfCode("squid")).isFalse(); } |
CodeRecognizer { public final List<String> extractCodeLines(List<String> lines) { List<String> codeLines = new ArrayList<>(); for (String line : lines) { if (recognition(line) >= threshold) { codeLines.add(line); } } return codeLines; } CodeRecognizer(double threshold, LanguageFootprint language); final double recognit... | @Test public void extractCodeLines() { CodeRecognizer cr = new CodeRecognizer(0.8, new FakeFootprint()); assertThat(cr.extractCodeLines(Arrays.asList("{", "squid"))).containsOnly("{"); } |
ProgressReport implements Runnable { public synchronized void cancel() { thread.interrupt(); join(); } ProgressReport(String threadName, long period, Logger logger, String adjective); ProgressReport(String threadName, long period, String adjective); ProgressReport(String threadName, long period); @Override void run()... | @Test(timeout = 5000) public void testCancel() throws InterruptedException { Logger logger = mock(Logger.class); ProgressReport report = new ProgressReport(ProgressReport.class.getName(), 100, logger, "analyzed"); report.start(Arrays.asList("foo.java")); waitForMessage(logger); report.cancel(); } |
ProfileGenerator { public static File generateProfile(String serverUrl, String language, String repository, RulesConfiguration rulesConfiguration, Set<String> excludedRules) { try { Set<String> ruleKeys = getRuleKeys(serverUrl, language, repository); ruleKeys.removeAll(excludedRules); return generateProfile(language, r... | @Test public void test_generation_of_profile() throws Exception { ProfileGenerator.RulesConfiguration rulesConfiguration = new ProfileGenerator.RulesConfiguration() .add("S1451", "headerFormat", " .add("S1451", "isRegularExpression", "true") .add("S2762", "threshold", "1"); Set<String> rules = new HashSet<>(Arrays.asLi... |
JsonParser { Map<String, Object> parse(String data) { try { return (Map<String, Object>) parser.parse(data); } catch (ParseException e) { throw new IllegalArgumentException("Could not parse JSON", e); } } } | @Test public void parse() throws Exception { JsonParser parser = new JsonParser(); Map<String, Object> map = parser.parse("{ \"name\" : \"Paul\" }"); Object name = map.get("name"); assertThat(name).isEqualTo("Paul"); }
@Test(expected = IllegalArgumentException.class) public void invalid_json() { new JsonParser().parse(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.