MappingUtils { public static MappingAdmin getMappingAdmin( ConfigurationProducer cProducer ) throws HBaseConnectionException { HBaseConnection hbConnection = null; try { hbConnection = cProducer.getHBaseConnection(); hbConnection.checkHBaseAvailable(); return new MappingAdmin( hbConnection ); } catch ( ClusterInitializationException | IOException e ) { throw new HBaseConnectionException( Messages.getString( "MappingDialog.Error.Message.UnableToConnect" ), e ); } }  static MappingAdmin getMappingAdmin( ConfigurationProducer cProducer ); static MappingAdmin getMappingAdmin( HBaseService hBaseService, VariableSpace variableSpace, String siteConfig,
      String defaultConfig ); static Mapping getMapping( MappingDefinition mappingDefinition, HBaseService hBaseService ); static HBaseValueMetaInterface buildNonKeyValueMeta( String alias, String family, String columnName,
      String type, String indexedVals, HBaseService hBaseService ); static boolean isTupleMapping( MappingDefinition mappingDefinition ); static boolean isTupleMappingColumn( String columnName ); static final int TUPLE_COLUMNS_COUNT; static final int UNDEFINED_VALUE; static final String TUPLE_MAPPING_VISIBILITY; }
@Test public void testGetMappingAdmin_NoException() { try { when( cProducerMock.getHBaseConnection() ).thenReturn( hbConnectionMock ); MappingAdmin mappingAdmin = MappingUtils.getMappingAdmin( cProducerMock ); assertNotNull( mappingAdmin ); assertSame( hbConnectionMock, mappingAdmin.getConnection() ); verify( hbConnectionMock ).checkHBaseAvailable(); } catch ( Exception e ) { fail( "No exception expected but it occurs!" ); } }
@Test public void testGetMappingAdmin_ClusterInitializationExceptionToHBaseConnectionException() throws Exception { ClusterInitializationException clusterInitializationException = new ClusterInitializationException( new Exception( "ClusterInitializationException" ) ); try { when( cProducerMock.getHBaseConnection() ).thenThrow( clusterInitializationException ); MappingUtils.getMappingAdmin( cProducerMock ); fail( "Expected HBaseConnectionException but it doen not occur!" ); } catch ( HBaseConnectionException e ) { assertEquals( UNABLE_TO_CONNECT_TO_H_BASE, e.getMessage() ); assertSame( clusterInitializationException, e.getCause() ); } }
@Test public void testGetMappingAdmin_IOExceptionToHBaseConnectionException() throws Exception { IOException ioException = new IOException( "IOException" ); try { when( cProducerMock.getHBaseConnection() ).thenThrow( ioException ); MappingUtils.getMappingAdmin( cProducerMock ); fail( "Expected HBaseConnectionException but it doen not occur!" ); } catch ( HBaseConnectionException e ) { assertEquals( UNABLE_TO_CONNECT_TO_H_BASE, e.getMessage() ); assertSame( ioException, e.getCause() ); } }
@Test public void testGetMappingAdmin() throws IOException { HBaseService hBaseService = mock( HBaseService.class ); HBaseConnection hBaseConnection = mock( HBaseConnection.class ); when( hBaseService.getHBaseConnection( any( VariableSpace.class ), anyString(), anyString(), any( LogChannelInterface.class ) ) ).thenReturn( hBaseConnection ); VariableSpace variableSpace = mock( VariableSpace.class ); MappingUtils.getMappingAdmin( hBaseService, variableSpace, "SITE_CONFIG", "DEFAULT_CONFIG" ); }