test_class.declarator: authorizationTree
test_class.modifier: private
test_class.original_string: private AuthorizationTree authorizationTree;
test_class.type: AuthorizationTree
test_class.var_name: authorizationTree
test_class.file: org.eclipse.winery.accountability/src/test/java/org/eclipse/winery/accountability/model/authorization/AuthorizationTreeTest.java
test_class.identifier: AuthorizationTreeTest
test_case.body: @Test
      public void getLineage() {
          final Optional<List<AuthorizationNode>> lineage =
              this.authorizationTree.getAuthorizationLineage("0x3333");
  
          assertTrue(lineage.isPresent());
          assertEquals(3, lineage.get().size());
          assertEquals("0x3333", ((AuthorizationNode) lineage.get().toArray()[lineage.get().size() - 1]).getAddress());
          assertEquals("0x2222", ((AuthorizationNode) lineage.get().toArray()[lineage.get().size() - 2]).getAddress());
          assertEquals("0x1111", ((AuthorizationNode) lineage.get().toArray()[lineage.get().size() - 3]).getAddress());
      }
test_case.class_method_signature: AuthorizationTreeTest.getLineage()
test_case.full_signature: @Test public void getLineage()
test_case.identifier: getLineage
test_case.invocations: getAuthorizationLineage assertTrue isPresent assertEquals size get assertEquals getAddress toArray get size get assertEquals getAddress toArray get size get assertEquals getAddress toArray get size get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getLineage()
focal_class.declarator: SERVICE_OWNER_IDENTITY = "Service Owner"
focal_class.modifier: private static final
focal_class.original_string: private static final String SERVICE_OWNER_IDENTITY = "Service Owner";
focal_class.type: String
focal_class.var_name: SERVICE_OWNER_IDENTITY
focal_class.declarator: log = LoggerFactory.getLogger(AuthorizationTree.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(AuthorizationTree.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: tree
focal_class.modifier: private
focal_class.original_string: private Tree<AuthorizationNode> tree;
focal_class.type: Tree<AuthorizationNode>
focal_class.var_name: tree
focal_class.file: org.eclipse.winery.accountability/src/main/java/org/eclipse/winery/accountability/model/authorization/AuthorizationTree.java
focal_class.identifier: AuthorizationTree
focal_class.interfaces: implements AuthorizationInfo
focal_class.class_method_signature: AuthorizationTree.AuthorizationTree(List<AuthorizationElement> allAuthorizationElements)
focal_class.full_signature: public  AuthorizationTree(List<AuthorizationElement> allAuthorizationElements)
focal_class.identifier: AuthorizationTree
focal_class.modifiers: public
focal_class.parameters: (List<AuthorizationElement> allAuthorizationElements)
focal_class.signature:  AuthorizationTree(List<AuthorizationElement> allAuthorizationElements)
focal_class.class_method_signature: AuthorizationTree.isAuthorized(String blockchainAddress)
focal_class.full_signature: @Override public boolean isAuthorized(String blockchainAddress)
focal_class.identifier: isAuthorized
focal_class.modifiers: @Override public
focal_class.parameters: (String blockchainAddress)
focal_class.return: boolean
focal_class.signature: boolean isAuthorized(String blockchainAddress)
focal_class.class_method_signature: AuthorizationTree.getServiceOwnerBlockchainAddress()
focal_class.full_signature: @Override public Optional<String> getServiceOwnerBlockchainAddress()
focal_class.identifier: getServiceOwnerBlockchainAddress
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getServiceOwnerBlockchainAddress()
focal_class.class_method_signature: AuthorizationTree.getRealWorldIdentity(String blockchainAddress)
focal_class.full_signature: @Override public Optional<String> getRealWorldIdentity(String blockchainAddress)
focal_class.identifier: getRealWorldIdentity
focal_class.modifiers: @Override public
focal_class.parameters: (String blockchainAddress)
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getRealWorldIdentity(String blockchainAddress)
focal_class.class_method_signature: AuthorizationTree.getAuthorizationLineage(String blockchainAddress)
focal_class.full_signature: @Override public Optional<List<AuthorizationNode>> getAuthorizationLineage(String blockchainAddress)
focal_class.identifier: getAuthorizationLineage
focal_class.modifiers: @Override public
focal_class.parameters: (String blockchainAddress)
focal_class.return: Optional<List<AuthorizationNode>>
focal_class.signature: Optional<List<AuthorizationNode>> getAuthorizationLineage(String blockchainAddress)
focal_class.class_method_signature: AuthorizationTree.buildTree(List<AuthorizationElement> elements)
focal_class.full_signature: private Tree<AuthorizationNode> buildTree(List<AuthorizationElement> elements)
focal_class.identifier: buildTree
focal_class.modifiers: private
focal_class.parameters: (List<AuthorizationElement> elements)
focal_class.return: Tree<AuthorizationNode>
focal_class.signature: Tree<AuthorizationNode> buildTree(List<AuthorizationElement> elements)
focal_class.class_method_signature: AuthorizationTree.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_method.body: @Override
      public Optional<List<AuthorizationNode>> getAuthorizationLineage(String blockchainAddress) {
          // Find a strand that contains a node with the given blockchain address as authorized (each strand is ordered from
          // root to leaf)
          Optional<List<AuthorizationNode>> strandAsList =
              tree.getStrands()
                  .map(strand -> strand.collect(Collectors.toList()))
                  .filter(strand -> strand.stream().anyMatch(node -> node.getAddress().equals(blockchainAddress)))
                  .findFirst();
  
          // If we find the strand, build a path from node to root
          if (strandAsList.isPresent()) {
              final List<AuthorizationNode> result = new ArrayList<>();
  
              for (AuthorizationNode node : strandAsList.get()) {
                  result.add(node);
  
                  // add nodes up until the one we need
                  if (node.getAddress().equals(blockchainAddress))
                      break;
              }
  
              return Optional.of(result);
          } else {
              return Optional.empty();
          }
      }
focal_method.class_method_signature: AuthorizationTree.getAuthorizationLineage(String blockchainAddress)
focal_method.full_signature: @Override public Optional<List<AuthorizationNode>> getAuthorizationLineage(String blockchainAddress)
focal_method.identifier: getAuthorizationLineage
focal_method.invocations: findFirst filter map getStrands collect toList anyMatch stream equals getAddress isPresent get add equals getAddress of empty
focal_method.modifiers: @Override public
focal_method.parameters: (String blockchainAddress)
focal_method.return: Optional<List<AuthorizationNode>>
focal_method.signature: Optional<List<AuthorizationNode>> getAuthorizationLineage(String blockchainAddress)