From d8e1aa77c80fc7a4ad05072e23a39645d1f9256d Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Mon, 29 Apr 2019 19:23:00 -0700 Subject: [PATCH 1/4] Tests | Code Coverage improvement for DataClassification class + Fix conditional tests (#1041) --- .../resultset/DataClassificationTest.java | 52 ++++++--- .../sqlserver/jdbc/unit/UTF8SupportTest.java | 109 ++++++++---------- 2 files changed, 86 insertions(+), 75 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/resultset/DataClassificationTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/resultset/DataClassificationTest.java index 00897f566..19b1c97cc 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/resultset/DataClassificationTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/resultset/DataClassificationTest.java @@ -8,6 +8,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; +import java.util.List; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -17,6 +18,8 @@ import com.microsoft.sqlserver.jdbc.RandomUtil; import com.microsoft.sqlserver.jdbc.SQLServerResultSet; import com.microsoft.sqlserver.jdbc.TestUtils; +import com.microsoft.sqlserver.jdbc.dataclassification.InformationType; +import com.microsoft.sqlserver.jdbc.dataclassification.Label; import com.microsoft.sqlserver.jdbc.dataclassification.SensitivityProperty; import com.microsoft.sqlserver.testframework.AbstractSQLGenerator; import com.microsoft.sqlserver.testframework.AbstractTest; @@ -24,6 +27,7 @@ @RunWith(JUnitPlatform.class) +@Tag(Constants.xAzureSQLDB) @Tag(Constants.xAzureSQLDW) @Tag(Constants.xSQLv12) @Tag(Constants.xSQLv14) @@ -37,13 +41,11 @@ public class DataClassificationTest extends AbstractTest { */ @Test public void testDataClassificationMetadata() throws Exception { - // Run this test only with newer SQL Servers (version>=2018) that support Data Classification try (Statement stmt = connection.createStatement();) { - if (TestUtils.serverSupportsDataClassification(stmt)) { - createTable(connection, stmt); - runTestsForServer(stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(tableName), stmt); - } + assert (TestUtils.serverSupportsDataClassification(stmt)); + createTable(connection, stmt); + runTestsForServer(stmt); + TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(tableName), stmt); } } @@ -119,7 +121,7 @@ private void runTestsForServer(Statement stmt) throws Exception { } /** - * Verifies resultset received to contain data classification information as set. + * Verifies ResultSet received to contain data classification information as set. * * @param rs * @throws SQLException @@ -130,20 +132,36 @@ private void verifySensitivityClassification(SQLServerResultSet rs) throws SQLEx columnPos++) { for (SensitivityProperty sp : rs.getSensitivityClassification().getColumnSensitivities().get(columnPos) .getSensitivityProperties()) { + + List infoTypes = rs.getSensitivityClassification().getInformationTypes(); + assert (infoTypes.size() == 3); + for (int i = 0; i < infoTypes.size(); i++) { + verifyInfoType(infoTypes.get(i), i + 1); + } + + List