test_class.declarator: initializer
test_class.modifier: private
test_class.original_string: private PrivilegeInitializer initializer;
test_class.type: PrivilegeInitializer
test_class.var_name: initializer
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializerTest.java
test_class.identifier: PrivilegeInitializerTest
test_class.superclass: extends AbstractSecurityTest
test_case.body: @Test(expected = RuntimeException.class)
      public void testPrivilegeRegistrationFails() {
          try {
              NodeState ns = mock(NodeState.class);
              NodeBuilder nb = when(mock(NodeBuilder.class).hasChildNode(JCR_SYSTEM)).thenReturn(true).getMock();
              when(nb.getChildNode(anyString())).thenReturn(nb);
              when(nb.child(anyString())).thenReturn(nb);
              when(nb.getNodeState()).thenReturn(ns);
  
              Tree t = when(mock(Tree.class).exists()).thenReturn(true).getMock();
              when(t.hasChild(anyString())).thenReturn(true);
  
              Root r = when(mock(Root.class).getTree(anyString())).thenReturn(t).getMock();
              RootProvider rp = when(mock(RootProvider.class).createSystemRoot(any(NodeStore.class), isNull())).thenReturn(r).getMock();
              PrivilegeInitializer pi = new PrivilegeInitializer(rp);
              pi.initialize(nb);
          } catch (RuntimeException e) {
              assertTrue(e.getCause() instanceof RepositoryException);
              throw e;
          }
      }
test_case.class_method_signature: PrivilegeInitializerTest.testPrivilegeRegistrationFails()
test_case.full_signature: @Test(expected = RuntimeException.class) public void testPrivilegeRegistrationFails()
test_case.identifier: testPrivilegeRegistrationFails
test_case.invocations: mock getMock thenReturn when hasChildNode mock thenReturn when getChildNode anyString thenReturn when child anyString thenReturn when getNodeState getMock thenReturn when exists mock thenReturn when hasChild anyString getMock thenReturn when getTree mock anyString getMock thenReturn when createSystemRoot mock any isNull initialize assertTrue getCause
test_case.modifiers: @Test(expected = RuntimeException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPrivilegeRegistrationFails()
focal_class.declarator: log = LoggerFactory.getLogger(PrivilegeInitializer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(PrivilegeInitializer.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: rootProvider
focal_class.modifier: private final
focal_class.original_string: private final RootProvider rootProvider;
focal_class.type: RootProvider
focal_class.var_name: rootProvider
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java
focal_class.identifier: PrivilegeInitializer
focal_class.interfaces: implements RepositoryInitializer, PrivilegeConstants
focal_class.class_method_signature: PrivilegeInitializer.PrivilegeInitializer(@NotNull RootProvider rootProvider)
focal_class.full_signature:   PrivilegeInitializer(@NotNull RootProvider rootProvider)
focal_class.identifier: PrivilegeInitializer
focal_class.parameters: (@NotNull RootProvider rootProvider)
focal_class.signature:  PrivilegeInitializer(@NotNull RootProvider rootProvider)
focal_class.class_method_signature: PrivilegeInitializer.initialize(@NotNull NodeBuilder builder)
focal_class.full_signature: @Override public void initialize(@NotNull NodeBuilder builder)
focal_class.identifier: initialize
focal_class.modifiers: @Override public
focal_class.parameters: (@NotNull NodeBuilder builder)
focal_class.return: void
focal_class.signature: void initialize(@NotNull NodeBuilder builder)
focal_method.body: @Override
      public void initialize(@NotNull NodeBuilder builder) {
          if (!builder.hasChildNode(JcrConstants.JCR_SYSTEM)) {
              throw new IllegalStateException("Missing " + JcrConstants.JCR_SYSTEM + " node, NodeStore not initialized.");
          }
          NodeBuilder system = builder.getChildNode(JcrConstants.JCR_SYSTEM);
          if (!system.hasChildNode(REP_PRIVILEGES)) {
              NodeBuilder privileges = system.child(REP_PRIVILEGES);
              privileges.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGES, Type.NAME);
  
              // squeeze node state before it is passed to store (OAK-2411)
              NodeState base = squeeze(builder.getNodeState());
              NodeStore store = new MemoryNodeStore(base);
              try {
                  Root systemRoot = rootProvider.createSystemRoot(store, null);
                  new PrivilegeDefinitionWriter(systemRoot).writeBuiltInDefinitions();
              } catch (RepositoryException e) {
                  log.error("Failed to register built-in privileges", e);
                  throw new RuntimeException(e);
              }
              NodeState target = store.getRoot();
              target.compareAgainstBaseState(base, new ApplyDiff(builder));
          }
      }
focal_method.class_method_signature: PrivilegeInitializer.initialize(@NotNull NodeBuilder builder)
focal_method.full_signature: @Override public void initialize(@NotNull NodeBuilder builder)
focal_method.identifier: initialize
focal_method.invocations: hasChildNode getChildNode hasChildNode child setProperty squeeze getNodeState createSystemRoot writeBuiltInDefinitions error getRoot compareAgainstBaseState
focal_method.modifiers: @Override public
focal_method.parameters: (@NotNull NodeBuilder builder)
focal_method.return: void
focal_method.signature: void initialize(@NotNull NodeBuilder builder)