Skip to content

Commit d159b67

Browse files
committed
Updating the test cases
1 parent c54aad6 commit d159b67

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,9 +1032,7 @@ private void validateHttpStatusForNonLocalRootWithThrowableForClient(
10321032

10331033
@Test
10341034
public void testDBUserAttribute() {
1035-
mockAttribute(DB_SYSTEM, "db_system");
10361035
mockAttribute(DB_OPERATION, "db_operation");
1037-
mockAttribute(DB_STATEMENT, "db_statement");
10381036
mockAttribute(DB_USER, "db_user");
10391037
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
10401038

@@ -1046,6 +1044,7 @@ public void testDBUserAttribute() {
10461044

10471045
@Test
10481046
public void testDBUserAttributeAbsent() {
1047+
mockAttribute(DB_SYSTEM, "db_system");
10491048
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
10501049

10511050
Attributes actualAttributes =
@@ -1055,9 +1054,7 @@ public void testDBUserAttributeAbsent() {
10551054

10561055
@Test
10571056
public void testDBUserAttributeWithDifferentValues() {
1058-
mockAttribute(DB_SYSTEM, "db_system");
10591057
mockAttribute(DB_OPERATION, "db_operation");
1060-
mockAttribute(DB_STATEMENT, "db_statement");
10611058
mockAttribute(DB_USER, "non_db_user");
10621059
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
10631060

@@ -1068,8 +1065,8 @@ public void testDBUserAttributeWithDifferentValues() {
10681065

10691066
@Test
10701067
public void testDBUserAttributeNotPresentInServiceMetricForServerSpan() {
1071-
String dbUser = "db_user";
1072-
mockAttribute(DB_USER, dbUser);
1068+
mockAttribute(DB_USER, "db_user");
1069+
mockAttribute(DB_SYSTEM, "db_system");
10731070
when(spanDataMock.getKind()).thenReturn(SpanKind.SERVER);
10741071

10751072
Attributes actualAttributes =
@@ -1078,34 +1075,13 @@ public void testDBUserAttributeNotPresentInServiceMetricForServerSpan() {
10781075
}
10791076

10801077
@Test
1081-
public void testIsDbSpanTrueWhenDbSystemKeyIsPresent() {
1082-
mockAttribute(DB_SYSTEM, "DB system");
1083-
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
1084-
1085-
assertThat(AwsSpanProcessingUtil.isDBSpan(spanDataMock)).isTrue();
1086-
}
1087-
1088-
@Test
1089-
public void testIsDbSpanTrueWhenDbOperationKeyIsPresent() {
1090-
mockAttribute(DB_OPERATION, "DB operation");
1091-
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
1092-
1093-
assertThat(AwsSpanProcessingUtil.isDBSpan(spanDataMock)).isTrue();
1094-
}
1095-
1096-
@Test
1097-
public void testIsDbSpanFalseWhenOnlyDbUserKeyIsPresent() {
1078+
public void testDbUserPresentAndIsDbSpanFalse() {
10981079
mockAttribute(DB_USER, "DB user");
10991080
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
11001081

1101-
assertThat(AwsSpanProcessingUtil.isDBSpan(spanDataMock)).isFalse();
1102-
}
1103-
1104-
@Test
1105-
public void testIsDbSpanFalse() {
1106-
when(spanDataMock.getKind()).thenReturn(SpanKind.CLIENT);
1107-
1108-
assertThat(AwsSpanProcessingUtil.isDBSpan(spanDataMock)).isFalse();
1082+
Attributes actualAttributes =
1083+
GENERATOR.generateMetricAttributeMapFromSpan(spanDataMock, resource).get(DEPENDENCY_METRIC);
1084+
assertThat(actualAttributes.get(AWS_REMOTE_DB_USER)).isNull();
11091085
}
11101086

11111087
@Test

0 commit comments

Comments
 (0)