### Question:
QueryBlock { public synchronized HyperUser enroll() { checkConfig(); if (!user.isEnrolled()) { HFCAClient ca = userOrg.getCAClient(); try { ca.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite()); user.setEnrollment(ca.enroll(username, secret)); user.setMspId(userOrg.getMSPID()); if (adminName != null) { Store sampleStore = new Store(); HyperUser peerOrgAdmin = sampleStore.getMember( adminName, userOrg.getName(), userOrg.getMSPID(), conf.findFileSk(Paths.get(conf.getChannelPath(), "crypto-config/peerOrganizations/", userOrg.getDomainName(), format("/users/%s@%s/msp/keystore", adminName, userOrg.getDomainName())).toFile()), Paths.get( conf.getChannelPath(), "crypto-config/peerOrganizations/", userOrg.getDomainName(), format("/users/%s@%s/msp/signcerts/%s@%s-cert.pem", adminName, userOrg.getDomainName(), adminName, userOrg.getDomainName())).toFile()); userOrg.setPeerAdmin(peerOrgAdmin); } } catch (Exception e) { String errMsg = "Error enrolling user: " + username; logger.error(errMsg, e); throw new BlkchnException(errMsg, e); } } return user; } QueryBlock(String configPath, String channel, String username, String secret); Config getConf(); String getAdminName(); void setAdminName(String adminName); String getChannelName(); void setChannelName(String channelName); void setChannel(); Channel getChannel(); void checkConfig(); synchronized void registerUser(String uname, String secret, String affiliation); synchronized HyperUser enroll(); Channel reconstructChannel(); Channel reconstructChannel(List<Peer> peers, HFClient client); String installChaincode(String chaincodeName, String version, String goPath, String chaincodePath); String instantiateChaincode(String chaincodeName, String chainCodeVersion, String chainCodePath,
            String chaincodeFunction, String[] chaincodeArgs, Endorsers endorsers); DataFrame invokeChaincode(String chaincodename, String chaincodeFunction, String[] chaincodeArgs); String queryChaincode(String chaincodename, String chaincodeFunction, String[] chaincodeArgs); String upgradeChaincode(String chaincodeName, String chainCodeVersion, String chainCodePath,
            String chaincodeFunction, String[] chaincodeArgs, Endorsers endorsers); Long getChannelHeight();  }### Answer:
@Test public void testEnrollAndRegisterUser() throws ClassNotFoundException, SQLException, java.lang.Exception { String configPath = "src/test/resources/blockchain-query"; Class.forName("com.impetus.fabric.jdbc.FabricDriver"); QueryBlock qb = new QueryBlock(configPath,"mychannel", "test", "testpw"); HyperUser mockuser = mock(HyperUser.class); when(mockuser.isEnrolled()).thenReturn(true); Store mockStore = mock(Store.class); PowerMockito.whenNew(Store.class).withAnyArguments().thenReturn(mockStore); PowerMockito.mockStatic(HFCAClient.class); when(HFCAClient.createNewInstance(anyString(), any())).thenReturn(mockCA); Enrollment enrollment = mock(Enrollment.class); when(mockCA.enroll(anyString(), anyString())).thenReturn(enrollment); qb.enroll(); }