EncryptDALResultDecorator implements ResultDecorator { @Override public MergedResult decorate(final QueryResult queryResult, final SQLStatementContext<?> sqlStatementContext, final SchemaMetaData schemaMetaData) { return isNeedMergeEncryptColumns(sqlStatementContext.getSqlStatement()) ? new MergedEncryptColumnsMergedResult(queryResult, sqlStatementContext, schemaMetaData) : new TransparentMergedResult(queryResult); }  @Override MergedResult decorate(final QueryResult queryResult, final SQLStatementContext<?> sqlStatementContext, final SchemaMetaData schemaMetaData); @Override MergedResult decorate(final MergedResult mergedResult, final SQLStatementContext<?> sqlStatementContext, final SchemaMetaData schemaMetaData);  }
@Test public void assertMergedResultWithDescribeStatement() { schemaMetaData = mock(SchemaMetaData.class); sqlStatementContext = getDescribeStatementContext(); EncryptDALResultDecorator encryptDALResultDecorator = new EncryptDALResultDecorator(); assertThat(encryptDALResultDecorator.decorate(mock(QueryResult.class), sqlStatementContext, schemaMetaData), instanceOf(MergedEncryptColumnsMergedResult.class)); assertThat(encryptDALResultDecorator.decorate(mock(MergedResult.class), sqlStatementContext, schemaMetaData), instanceOf(DecoratedEncryptColumnsMergedResult.class)); }
@Test public void assertMergedResultWithShowColumnsStatement() { schemaMetaData = mock(SchemaMetaData.class); sqlStatementContext = getShowColumnsStatementContext(); EncryptDALResultDecorator encryptDALResultDecorator = new EncryptDALResultDecorator(); assertThat(encryptDALResultDecorator.decorate(mock(QueryResult.class), sqlStatementContext, schemaMetaData), instanceOf(MergedEncryptColumnsMergedResult.class)); assertThat(encryptDALResultDecorator.decorate(mock(MergedResult.class), sqlStatementContext, schemaMetaData), instanceOf(DecoratedEncryptColumnsMergedResult.class)); }
@Test public void assertMergedResultWithOtherStatement() { schemaMetaData = mock(SchemaMetaData.class); sqlStatementContext = mock(SQLStatementContext.class); EncryptDALResultDecorator encryptDALResultDecorator = new EncryptDALResultDecorator(); assertThat(encryptDALResultDecorator.decorate(mock(QueryResult.class), sqlStatementContext, schemaMetaData), instanceOf(TransparentMergedResult.class)); assertThat(encryptDALResultDecorator.decorate(mock(MergedResult.class), sqlStatementContext, schemaMetaData), instanceOf(MergedResult.class)); }