umustafi commented on a change in pull request #3299: URL: https://github.com/apache/gobblin/pull/3299#discussion_r649438980
########## File path: gobblin-runtime/src/test/java/org/apache/gobblin/runtime/troubleshooter/InMemoryIssueRepositoryTest.java ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.gobblin.runtime.troubleshooter; + +import java.util.List; + +import org.testng.annotations.Test; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + + +public class InMemoryIssueRepositoryTest { + + @Test + public void canPutIssue() + throws Exception { + + InMemoryIssueRepository repository = new InMemoryIssueRepository(); + + Issue testIssue = getTestIssue("first", "code1"); + repository.put(testIssue); + + List<Issue> issues = repository.getAll(); + assertEquals(1, issues.size()); + assertEquals(testIssue, issues.get(0)); + } + + @Test + public void canPutMultipleIssues() + throws Exception { + + InMemoryIssueRepository repository = new InMemoryIssueRepository(); + + repository.put(getTestIssue("first", "code1")); + repository.put(getTestIssue("second", "code2")); + repository.put(getTestIssue("third", "code3")); + + List<Issue> issues = repository.getAll(); + assertEquals(3, issues.size()); + assertTrue(issues.stream().anyMatch(i -> i.getCode().equals("code2"))); + } + + @Test + public void canRemoveIssue() + throws Exception { + + InMemoryIssueRepository repository = new InMemoryIssueRepository(); + + repository.put(getTestIssue("first", "code1")); + repository.put(getTestIssue("second", "code2")); + repository.put(getTestIssue("third", "code3")); + + List<Issue> issues = repository.getAll(); + assertEquals(3, issues.size()); + + repository.remove("code2"); + + issues = repository.getAll(); + assertEquals(2, issues.size()); + } + + @Test + public void canDeduplicateIssues() + throws Exception { + + InMemoryIssueRepository repository = new InMemoryIssueRepository(); + + repository.put(getTestIssue("first", "code1")); + repository.put(getTestIssue("second", "code2")); + repository.put(getTestIssue("second-2", "code2")); + repository.put(getTestIssue("second-3", "code2")); + + List<Issue> issues = repository.getAll(); + assertEquals(2, issues.size()); + assertTrue(issues.stream().anyMatch(i -> i.getCode().equals("code1"))); + assertTrue(issues.stream().anyMatch(i -> i.getCode().equals("code2"))); Review comment: Does this account for a case where we have multiple issues with the same code that originated from two different places or does this usually map to propagated errors? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
