Skip to content

Commit

Permalink
Add multi orgs headers and calculate order from top org to bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
pstreef committed May 7, 2024
1 parent 563191e commit 5c3670c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class OrganizationStructureService {
public Map<String, OrganizationRepositories> readOrganizationStructure() {
LinkedHashMap<String, OrganizationRepositories> organizations = new LinkedHashMap<>();
Set<RepositoryInput> allRepositories = new LinkedHashSet<>();
organizations.put("ALL", new OrganizationRepositories("ALL", allRepositories, List.of(CommitOption.values()), null));

try (BufferedReader reader = new BufferedReader(new InputStreamReader(new ClassPathResource(REPOS_CSV).getInputStream()))) {
reader.readLine(); // skip header
Expand All @@ -45,7 +44,7 @@ public Map<String, OrganizationRepositories> readOrganizationStructure() {
RepositoryInput repository = new RepositoryInput(path, origin, branch);
allRepositories.add(repository);

for (int i = 2; i < fields.length; i++) {
for (int i = fields.length - 1; i > 1; i--) {
boolean first = i == 2;
String organization = fields[i].trim();
String parent = fields.length > i + 1 ? fields[i + 1].trim() : null;
Expand All @@ -66,6 +65,7 @@ public Map<String, OrganizationRepositories> readOrganizationStructure() {
} catch (IOException e) {
throw new RuntimeException(e);
}
organizations.put("ALL", new OrganizationRepositories("ALL", allRepositories, List.of(CommitOption.values()), null));
return organizations;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/repos.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cloneUrl,branch,org1,orgN
cloneUrl,branch,org1,org2,org3,org4,org5,org6,org7,org8,org9,org10
https://github.com/openrewrite/rewrite-recipe-bom,main,Default,ALL
https://github.com/openrewrite/rewrite-recommendations,main,Default,ALL
https://github.com/WebGoat/WebGoat,main,Default,ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ public class OrganizationDataFetcherTest {
void organizationsStructure() {
StepVerifier
.create(organizationDataFetcher.allOrganizations())
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("Default");
assertThat(next.getParent().getId()).isEqualTo("ALL");
})
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("ALL");
assertThat(next.getParent()).isNull();
})
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("OpenRewrite");
assertThat(next.getParent().getId()).isEqualTo("Open source");
assertThat(next.getId()).isEqualTo("Default");
assertThat(next.getParent().getId()).isEqualTo("ALL");
})
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("Open source");
assertThat(next.getParent().getId()).isEqualTo("ALL");
})
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("OpenRewrite");
assertThat(next.getParent().getId()).isEqualTo("Open source");
})
.assertNext(next -> {
assertThat(next.getId()).isEqualTo("WebGoat");
assertThat(next.getParent().getId()).isEqualTo("Open source");
Expand Down

0 comments on commit 5c3670c

Please sign in to comment.