Skip to content

Commit

Permalink
Merge pull request #952 from rax-maas/tracker-test-fix
Browse files Browse the repository at this point in the history
fix TrackerTest failure
  • Loading branch information
iWebi committed Sep 23, 2022
2 parents 03c8a29 + 7b9f0ed commit 0bda3ef
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -22,6 +22,7 @@
import org.powermock.modules.junit4.PowerMockRunner;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class TrackerTest {
private long collectionTime;

@Captor
ArgumentCaptor argCaptor;
ArgumentCaptor<String> argCaptor;

@BeforeClass
public static void setupClass() {
Expand Down Expand Up @@ -268,9 +269,17 @@ public void testTrackTenant() throws Exception {
tracker.track(httpRequestMock);

// verify
verify(loggerMock, atLeastOnce()).info("[TRACKER] tenantId " + tenantId + " added.");
verify(loggerMock, atLeastOnce()).info((String)argCaptor.capture());
assertThat(argCaptor.getValue().toString(), containsString("[TRACKER] POST request for tenantId " + tenantId + ": /v2.0/" + tenantId + "/ingest?param1=value1&param1=value2\n" +
verify(loggerMock, atLeastOnce()).info(argCaptor.capture());
List<String> allValues = argCaptor.getAllValues();
for (int i = 0; i < allValues.size(); i++) {
System.out.println("logged " + i + ": " + allValues.get(i));
}
assertThat(allValues.size(), equalTo(3));
// Where does "all tenants removed" come from? I don't know. I don't grok this thing yet, but this is what
// happens when you run the test.
assertThat(allValues.get(0), equalTo("[TRACKER] all tenants removed."));
assertThat(allValues.get(1), equalTo("[TRACKER] tenantId " + tenantId + " added."));
assertThat(allValues.get(2), equalTo("[TRACKER] POST request for tenantId " + tenantId + ": /v2.0/" + tenantId + "/ingest?param1=value1&param1=value2\n" +
"HEADERS: \n" +
"X-Auth-Token\tAUTHTOKEN\n" +
"REQUEST_CONTENT:\n" +
Expand Down

0 comments on commit 0bda3ef

Please sign in to comment.