method2testcases
stringlengths
118
6.63k
### Question: CategoryServiceImpl implements CategoryService { @Override public void deleteCategoryById(Long id) { categoryRepository.delete(id); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void up...
### Question: CategoryServiceImpl implements CategoryService { @Override public void updateCategory(Category category) { categoryRepository.save(category); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Overri...
### Question: CategoryServiceImpl implements CategoryService { @Override public Iterable<Category> findAll() { return categoryRepository.findAll(); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void ...
### Question: CategoryServiceImpl implements CategoryService { @Override public Category findCategoryById(Long id) { return categoryRepository.findOne(id); } @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Overri...
### Question: CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber) { PageRequest pageRequest = new PageRequest(starPage,itemNumber); return categoryRepository.findAll(pageRequest); } @Override void saveCategory(Category category); @Ov...
### Question: CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumb...
### Question: FF4JMBean { public void setFf4j(FF4j ff4j) { this.ff4j = ff4j; } @ManagedAttribute(description = "Returns states of every features of the store") Map<String, Boolean> getFeaturesStatus(); @ManagedOperation(description = "Enable feature from its identifier") @ManagedOperationParameters({@ManagedOperationP...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override public Iterator<String> getKeys(String prefix) { Set< String > setOfNames = ff4jStore().listPropertyNames(); Set< String > results = new HashSet<String>(); if (setOfNames != null && setOfNames.size() > 0) { for (String name : setOfNames) { if (na...
### Question: FF4jConfiguration extends AbstractConfiguration { public PropertyStore ff4jStore() { if (ff4jStore == null) { throw new IllegalStateException("Cannot load property from store as not initialized please set 'ff4jStore' property"); } return getFf4jStore(); } FF4jConfiguration(); FF4jConfiguration(PropertySt...
### Question: PropertyStoreCommonsConfig extends AbstractPropertyStore { @Override public boolean existProperty(String name) { Util.assertHasLength(name); return conf().containsKey(name); } PropertyStoreCommonsConfig(); PropertyStoreCommonsConfig(Configuration configuration); @Override boolean existProperty(String nam...
### Question: YamlParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile =...
### Question: PropertyJsonParser { @SuppressWarnings("unchecked") public static Property<?> parseProperty(String json) { if (null == json || "".equals(json)) { return null; } Map<String, Object> propertyJson; try { propertyJson = objectMapper.readValue(json, HashMap.class); } catch (Exception re) { throw new IllegalArg...
### Question: FeatureJsonParser { @SuppressWarnings("unchecked") public static Feature parseFeature(String json) { try { return parseFeatureMap(objectMapper.readValue(json, HashMap.class)); } catch (IOException e) { throw new IllegalArgumentException("Cannot parse json as Feature " + json, e); } } private FeatureJsonP...
### Question: FeatureJsonParser { @SuppressWarnings("unchecked") public static Feature[] parseFeatureArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> flipMap = objectMapper.readValue(json, List.class); Feature[] fArray = new Feature[flipMap.size()]; in...
### Question: PropertiesParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); try { Properties props = new Properties(); props.l...
### Question: FeatureJsonParser { public static String featureArrayToJson(Feature[] features) { StringBuilder sb = new StringBuilder(); sb.append("["); if (features != null) { boolean first = true; for (Feature feature : features) { sb.append(first ? "" : ","); sb.append(feature.toJson()); first = false; } } sb.append(...
### Question: FeatureJsonParser { @SuppressWarnings("unchecked") public static FlippingStrategy parseFlipStrategyAsJson(String uid, String json) { if (null == json || "".equals(json)) { return null; } try { return parseFlipStrategy(uid, (HashMap<String, Object>) objectMapper.readValue(json, HashMap.class)); } catch (Ex...
### Question: EventJsonParser { @SuppressWarnings("unchecked") public static Event parseEvent(String json) { try { return parseEventMap(objectMapper.readValue(json, HashMap.class)); } catch (IOException e) { throw new IllegalArgumentException("Cannot parse json as Event " + json, e); } } private EventJsonParser(); @Su...
### Question: EventJsonParser { public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.to...
### Question: EventJsonParser { @SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; f...
### Question: PropertyStoreAwsSSM extends AbstractPropertyStore { @Override public void clear() { Set<String> names = listPropertyFullNames(); if (!Util.isEmpty(names)) { client.deleteParameters(new DeleteParametersRequest().withNames(names)); } } PropertyStoreAwsSSM(String path); PropertyStoreAwsSSM(AWSSimpleSystemsM...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override public Configuration subset(String prefix) { Map < String, Property<?>> myProps = ff4jStore().readAllProperties(); PropertyStore ps = new InMemoryPropertyStore(); for (Map.Entry< String, Property<?>> prop : myProps.entrySet()) { if (prop.getKey()...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override public void addProperty(String key, Object value) { ff4jStore().createProperty(PropertyFactory.createProperty(key, value)); } FF4jConfiguration(); FF4jConfiguration(PropertyStore ff4jPropertyStore); @Override Configuration subset(String prefix);...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override protected void addPropertyDirect(String key, Object value) { ff4jStore().createProperty(PropertyFactory.createProperty(key, value)); } FF4jConfiguration(); FF4jConfiguration(PropertyStore ff4jPropertyStore); @Override Configuration subset(String...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override public void clearProperty(String key) { ff4jStore().deleteProperty(key); } FF4jConfiguration(); FF4jConfiguration(PropertyStore ff4jPropertyStore); @Override Configuration subset(String prefix); @Override Properties getProperties(String key); @O...
### Question: FF4jConfiguration extends AbstractConfiguration { @Override public void clear() { ff4jStore().clear(); } FF4jConfiguration(); FF4jConfiguration(PropertyStore ff4jPropertyStore); @Override Configuration subset(String prefix); @Override Properties getProperties(String key); @Override boolean isEmpty(); @Ov...
### Question: Util { @Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest...
### Question: SimpleTextFormat implements Format { @Override public String format(@Nonnull final LogContext log) { final StringBuilder builder = new StringBuilder(); for (final Token token : tokens) { token.append(log, builder); } return builder.toString(); } SimpleTextFormat(@Nonnull final String format); SimpleTextF...
### Question: SmartLog { @Nonnull public static LogContext current() { final Deque<LogContext> contextQueue = CONTEXTS.get(); if (!contextQueue.isEmpty()) { return contextQueue.peek(); } else { throw new RuntimeException("Loggable context is absent"); } } @Nonnull static LogContext start(@Nonnull final Output output);...
### Question: SmartLog { public static void finish() { final Deque<LogContext> list = CONTEXTS.get(); if (!list.isEmpty()) { final LogContext ctx = list.pop(); final Object loggableObject = ctx.loggableObject(); if (loggableObject != null && loggableObject instanceof LoggableCallback) { final LoggableCallback callback ...
### Question: Util { @Nonnull public static Class findRootEnclosingClass(@Nonnull final Class clazz) { Class curr = clazz; while (true) { Class declaringClass = curr.getEnclosingClass(); if (declaringClass != null) { curr = declaringClass; } else { return curr; } } } @Nonnull static String stripCrLf(@Nonnull final Str...
### Question: Slf4JOutput implements Output { public static Builder create() { return new Builder(); } Slf4JOutput(final Builder builder); static Builder create(); @Override void write(final LogContext log); @Nonnull Logger getLogger(); @Nullable Format getFormat(); @Nullable Boolean getReplaceCrLf(); }### Answer: @Te...
### Question: DynamicPropertiesRule implements Rule<JDefinedClass, JDefinedClass> { JFieldRef getOrAddNotFoundVar(JDefinedClass jclass) { jclass.field(PROTECTED | STATIC | FINAL, Object.class, NOT_FOUND_VALUE_FIELD, _new(jclass.owner()._ref(Object.class))); return jclass.staticRef(NOT_FOUND_VALUE_FIELD); } DynamicPrope...
### Question: LanguageFeatures { public static boolean canUseJava7(GenerationConfig config) { return !LESS_THAN_7.contains(config.getTargetVersion()); } static boolean canUseJava7(GenerationConfig config); static boolean canUseJava8(GenerationConfig config); }### Answer: @Test public void correctTestForJava7() { asse...
### Question: Arguments implements GenerationConfig { public Arguments parse(String[] args) { JCommander jCommander = new JCommander(this); jCommander.setProgramName("jsonschema2pojo"); try { jCommander.parse(args); if (this.showHelp) { jCommander.usage(); exit(EXIT_OKAY); } } catch (ParameterException e) { System.err....
### Question: ClassConverter extends BaseConverter<Class> { @Override public Class convert(String value) { if (isBlank(value)) { throw new ParameterException(getErrorString("a blank value", "a class")); } try { return Class.forName(value); } catch (ClassNotFoundException e) { throw new ParameterException(getErrorString...
### Question: UrlConverter extends BaseConverter<URL> { public URL convert(String value) { if (isBlank(value)) { throw new ParameterException(getErrorString("a blank value", "a valid URL")); } try { return URLUtil.parseURL(value); } catch (IllegalArgumentException e) { throw new ParameterException(getErrorString(value,...
### Question: LanguageFeatures { public static boolean canUseJava8(GenerationConfig config) { return !LESS_THAN_8.contains(config.getTargetVersion()); } static boolean canUseJava7(GenerationConfig config); static boolean canUseJava8(GenerationConfig config); }### Answer: @Test public void correctTestForJava8() { asse...
### Question: MakeUniqueClassName { public static String makeUnique(String className) { final Matcher m = UNIQUE_NAMING_PATTERN.matcher(className); if (m.matches()) { final Integer number = Integer.parseInt(m.group(2)); return m.group(1) + (number + 1); } else { return className + "__1"; } } static String makeUnique(S...
### Question: NameHelper { public String getGetterName(String propertyName, JType type, JsonNode node) { propertyName = getPropertyNameForAccessor(propertyName, node); String prefix = type.equals(type.owner()._ref(boolean.class)) ? "is" : "get"; String getterName; if (propertyName.length() > 1 && Character.isUpperCase(...
### Question: NameHelper { public String getSetterName(String propertyName, JsonNode node) { propertyName = getPropertyNameForAccessor(propertyName, node); String prefix = "set"; String setterName; if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) { setterName = prefix + propertyName; } el...
### Question: NameHelper { public String getBuilderName(String propertyName, JsonNode node) { propertyName = getPropertyNameForAccessor(propertyName, node); String prefix = "with"; if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) { return prefix + propertyName; } else { return prefix + ca...
### Question: NameHelper { public String getClassName(String propertyName, JsonNode node) { if (node != null) { if (node.has("javaName")) { propertyName = node.get("javaName").textValue(); } else if (generationConfig.isUseTitleAsClassname() && node.has("title")) { String title = node.get("title").textValue(); propertyN...
### Question: TypeUtil { public static JClass resolveType(JClassContainer _package, String typeDefinition) { try { FieldDeclaration fieldDeclaration = (FieldDeclaration) JavaParser.parseBodyDeclaration(typeDefinition + " foo;"); ClassOrInterfaceType c = (ClassOrInterfaceType) ((ReferenceType) fieldDeclaration.getType()...
### Question: AnnotatorFactory { public Annotator getAnnotator(AnnotationStyle style) { switch (style) { case JACKSON: case JACKSON2: return new Jackson2Annotator(generationConfig); case JACKSON1: return new Jackson1Annotator(generationConfig); case GSON: return new GsonAnnotator(generationConfig); case MOSHI1: return ...
### Question: ContentResolver { public JsonNode resolve(URI uri) { if (CLASSPATH_SCHEMES.contains(uri.getScheme())) { return resolveFromClasspath(uri); } try { return objectMapper.readTree(uri.toURL()); } catch (JsonProcessingException e) { throw new IllegalArgumentException("Error parsing document: " + uri, e); } catc...
### Question: PatternRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { JAnnotationUse annotation = field....
### Question: FormatRule implements Rule<JType, JType> { @Override public JType apply(String nodeName, JsonNode node, JsonNode parent, JType baseType, Schema schema) { Class<?> type = getType(node.asText()); if (type != null) { JType jtype = baseType.owner().ref(type); if (ruleFactory.getGenerationConfig().isUsePrimiti...
### Question: DescriptionRule implements Rule<JDocCommentable, JDocComment> { @Override public JDocComment apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema) { JDocComment javadoc = generatableType.javadoc(); String descriptionText = node.asText(); if(StringUtils.isNo...
### Question: DigitsRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && i...
### Question: RequiredArrayRule implements Rule<JDefinedClass, JDefinedClass> { @Override public JDefinedClass apply(String nodeName, JsonNode node, JsonNode parent, JDefinedClass jclass, Schema schema) { List<String> requiredFieldMethods = new ArrayList<>(); JsonNode properties = schema.getContent().get("properties");...
### Question: Inflector { public String singularize(String word) { if (uncountables.contains(word.toLowerCase())) { return word; } return replaceWithFirstRule(word, singulars); } private Inflector(Builder builder); static Inflector.Builder createDefaultBuilder(); static Inflector getInstance(); String pluralize(String...
### Question: EnumRule implements Rule<JClassContainer, JType> { @Override public JType apply(String nodeName, JsonNode node, JsonNode parent, JClassContainer container, Schema schema) { JDefinedClass _enum; try { _enum = createEnum(node, nodeName, container); } catch (ClassAlreadyExistsException e) { ruleFactory.getLo...
### Question: RequiredRule implements Rule<JDocCommentable, JDocCommentable> { @Override public JDocCommentable apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema) { if (node.asBoolean()) { generatableType.javadoc().append("\n(Required)"); if (ruleFactory.getGeneration...
### Question: TitleRule implements Rule<JDocCommentable, JDocComment> { @Override public JDocComment apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema) { JDocComment javadoc = generatableType.javadoc(); javadoc.add(0, node.asText() + "\n<p>\n"); return javadoc; } prot...
### Question: Inflector { public String pluralize(String word) { if (uncountables.contains(word.toLowerCase())) { return word; } return replaceWithFirstRule(word, plurals); } private Inflector(Builder builder); static Inflector.Builder createDefaultBuilder(); static Inflector getInstance(); String pluralize(String wor...
### Question: AsyncCountDownLatch extends CountDownLatch implements Completable.Source { @Override public void subscribe(Completable.Observer subscriber) { completionSignal.subscribe(subscriber); } AsyncCountDownLatch(int count); boolean isCompleted(); @Override void subscribe(Completable.Observer subscriber); void cou...
### Question: Loader { public abstract void load() throws Exception; Loader(final String databaseName, final SparkSession spark, final DatabaseStatistics statistics); abstract void load(); }### Answer: @Test void propertyTableTest() { final Settings settings = new Settings.Builder("testingDB").build(); final DatabaseS...
### Question: FileService { @Transactional public List listAllFiles(){ return fileDao.listAllFiles(); } @Autowired void setFileDao(FileDao fileDao); boolean insert(File file); @Transactional List listAllFiles(); @Transactional boolean deleteFile(int id); }### Answer: @Test public void testListAllFiles()throws Excepti...
### Question: UserService { public User createUser(User user) { passwordHelper.encryptPassword(user); return userDao.createUser(user); } User createUser(User user); User updateUser(User user); void deleteUser(Long userId); User findOne(Long userId); List<User> findAll(); void changePassword(Long userId, String newPass...
### Question: HMACSignature { public static String calculateRFC2104HMAC(String data, String key) throws java.security.SignatureException { String result = null; try { Charset utf8ChartSet = Charset.forName("UTF-8"); SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(utf8ChartSet), HMAC_SHA1_ALGORITHM); Mac mac =...
### Question: AcronymGeneratorImpl implements AcronymGenerator { @Override public String generate(String givenNames, String surname) { Assert.hasText(givenNames, "Given name is required"); Assert.hasText(surname, "Surname is required"); int wordsSize = 0; wordsSize += givenNames.length(); wordsSize += surname.length();...
### Question: QuestionnairesUI extends UI { @Override public void init(VaadinRequest request) { logger.info("New Vaadin UI created"); String invitation = request.getParameter("invitation"); logger.info("Invitation: {} of sessions : {}", invitation); setSizeFull(); GazpachoViewDisplay viewDisplay = new GazpachoViewDispl...
### Question: ObjectHandler implements Serializable { public Serializable getObject() { return (Serializable) object; } ObjectHandler(Object obj); boolean isGraalObject(); boolean isGraalObject(Object object); Object invoke(String method, ArrayList<Object> params); Serializable getObject(); void setObject(Serializable ...
### Question: Utils { public static boolean isImmutableMethod( Class<?> clazz, String methodName, ArrayList<Object> params) { if (clazz == null) { throw new NullPointerException("Class not specified"); } if (methodName == null || methodName.trim().isEmpty()) { throw new IllegalArgumentException("method name not specifi...
### Question: ServerInfo implements Serializable { public void addLabels(Map keyValues) { if (keyValues == null) { throw new NullPointerException("Labels must not be null"); } this.labels.putAll(keyValues); } ServerInfo(InetSocketAddress addr); InetSocketAddress getHost(); String getRegion(); void addLabels(Map keyValu...
### Question: Server implements RemoteRaftServer { public UUID getMyServerID() { return pState.myServerID; } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex, int prevLogTerm, ...
### Question: Server implements RemoteRaftServer { RemoteRaftServer getCurrentLeader() { return getServer(vState.getCurrentLeader()); } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex, ...
### Question: Server implements RemoteRaftServer { int majorityQuorumSize() { int f = fullQuorumSize() / 2 + 1; return f; } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex, in...
### Question: Server implements RemoteRaftServer { int fullQuorumSize() { return vState.otherServers.size() + 1; } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex, int prevLog...
### Question: Server implements RemoteRaftServer { RemoteRaftServer getServer(UUID serverId) { return vState.otherServers.get( serverId); } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex...
### Question: Server implements RemoteRaftServer { public void addServer(UUID id, RemoteRaftServer server) { vState.otherServers.put(id, server); } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prev...
### Question: Server implements RemoteRaftServer { public void start() { this.become(State.FOLLOWER, vState.getState()); } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries( int term, UUID leader, int prevLogIndex, int...
### Question: Server implements RemoteRaftServer { synchronized State become(State newState, State preconditionState) { if (vState.getState() == preconditionState) { switch (vState.getState()) { case NONE: break; case LEADER: leader.stop(); break; case FOLLOWER: follower.stop(); break; case CANDIDATE: candidate.stop();...
### Question: Server implements RemoteRaftServer { public int requestVote(int term, UUID candidate, int lastLogIndex, int lastLogTerm) throws InvalidTermException, AlreadyVotedException, CandidateBehindException { logger.fine( String.format( "%s received vote request from %s (term=%d, lastLogIndex=%d, lastLogTerm=%d)",...
### Question: Server implements RemoteRaftServer { void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applyin...
### Question: Server implements RemoteRaftServer { void respondToRemoteTerm(int remoteTerm) { int currentTerm = pState.getCurrentTerm(); if (currentTerm < remoteTerm) { pState.setCurrentTerm(remoteTerm, currentTerm); become(State.FOLLOWER, vState.getState()); } } Server(StateMachineApplier applier); UUID getMyServerID(...
### Question: Server implements RemoteRaftServer { public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { thr...
### Question: AppObjectSandboxProvider implements SandboxProvider, Serializable { @Override public ServerUpcalls getSandbox(ServerPolicyLibrary origin, UUID transactionId) throws Exception { if (!this.sandboxes.containsKey(transactionId)) { AppObjectShimServerPolicy sandbox = AppObjectShimServerPolicy.cloneInShimServer...
### Question: AppObjectShimServerPolicy extends DefaultPolicy.DefaultServerPolicy { public static AppObjectShimServerPolicy cloneInShimServerPolicy(AppObject appObject) throws Exception { AppObject deepCloneAppObject = (AppObject) Utils.ObjectCloner.deepCopy(appObject); return new AppObjectShimServerPolicy(appObject, d...
### Question: TransactionWrapper { public ArrayList<Object> getRPCParams() { return getTransactionRPCParams(this.transactionId, this.rpcMethod, this.rpcParams); } TransactionWrapper(String method, ArrayList<Object> params); TransactionWrapper(UUID txnId, String method, ArrayList<Object> params); static ArrayList<Objec...
### Question: TwoPCLocalParticipants implements Serializable { public void fanOutTransactionPrimitive(UUID transactionId, String primitiveMethod) throws TransactionExecutionException { ArrayList<Object> paramsTX = TransactionWrapper.getTransactionRPCParams(transactionId, primitiveMethod, null); TransactionContext.enter...
### Question: TwoPCLocalParticipants implements Serializable { public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction...
### Question: TLSTransactionManager implements TransactionManager, Serializable { @Override public void commit(UUID transactionId) { this.localStatusManager.setStatus(transactionId, LocalStatus.COMMITTED); this.validator.onCommit(transactionId); try { this.localParticipantsManager.fanOutTransactionPrimitive( transactio...
### Question: TLSTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; c...
### Question: TLS2PCCoordinator implements TwoPCCoordinator { @Override public void beginTransaction() throws TransactionAlreadyStartedException { if (TransactionContext.getCurrentTransaction() != null) { throw new TransactionAlreadyStartedException("nested transaction is unsupported."); } UUID transactionId = UUID.ran...
### Question: TLS2PCCoordinator implements TwoPCCoordinator { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { try { if (!this.validator.promises(transactionId)) { return Vote.NO; } } catch (Exception e) { logger.log(Level.SEVERE, "coordinator 2PC preparation failed", e); return Vot...
### Question: ExtResourceTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { Vote vote = this.internalTransactionManager.vote(transactionId); if (vote.equals(Vote.YES)) { Vote voteExtResource = this.getBusinessObject(tran...
### Question: ExtResourceTransactionManager implements TransactionManager, Serializable { @Override public void commit(UUID transactionId) { this.getBusinessObject(transactionId).commit(transactionId); this.internalTransactionManager.commit(transactionId); } ExtResourceTransactionManager( SandboxProvider sa...
### Question: FlagValueCalculator { @Nullable public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { State value = null; for (StateFlag flag : flags) { value = StateFlag.combine(value, queryValue(subject, flag)); if (value == State.DENY) { break; } } return value; } FlagValueCalculator(List<P...
### Question: FlagValueCalculator { public int getPriority(final ProtectedRegion region) { if (region == globalRegion) { return Integer.MIN_VALUE; } else { return region.getPriority(); } } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); Result getMembership(RegionAssociable s...
### Question: PathMatchers { @Factory public static Matcher<Path> contains(String fileName) { return new DirectoryContains(fileName); } PathMatchers(); @Factory static Matcher<Path> contains(String fileName); @Factory static Matcher<Path> isDirectory(); @Factory static Matcher<Path> exists(LinkOption... options); @Fact...
### Question: PathMatchers { @Factory public static Matcher<Path> exists(LinkOption... options) { return new Exists(options); } PathMatchers(); @Factory static Matcher<Path> contains(String fileName); @Factory static Matcher<Path> isDirectory(); @Factory static Matcher<Path> exists(LinkOption... options); @Factory stat...
### Question: PathMatchers { @Factory public static Matcher<Path> hasFilesCount(int expectedCount) { return new FilesCount(expectedCount); } PathMatchers(); @Factory static Matcher<Path> contains(String fileName); @Factory static Matcher<Path> isDirectory(); @Factory static Matcher<Path> exists(LinkOption... options); ...
### Question: SameAsURIMatcher extends TypeSafeDiagnosingMatcher<URI> { @Factory public static SameAsURIMatcher sameAsURI(URI expectedUri) { return new SameAsURIMatcher(expectedUri); } private SameAsURIMatcher(URI expectedUri); @Override void describeTo(Description description); SameAsURIMatcher filteredWith(UriDiffFi...
### Question: Wrapper { public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; } Wrapper<T> wrap(T wrapped); T getWrapped(); void setPosition(int position); int getPosition(); @Override int hashCode(); @Override @SuppressWarnings("unchecked") boolean equals(Object obj); @Override String toString(); a...
### Question: HasSameItemsAsListMatcher extends TypeSafeDiagnosingMatcher<List<? extends T>> { @Factory public static <T> HasSameItemsAsListMatcher<T> hasSameItemsAsList(List<? extends T> correctList) { return new HasSameItemsAsListMatcher<>(correctList); } HasSameItemsAsListMatcher(List<? extends T> expect); HasSameIt...
### Question: HasSameItemsAsCollectionMatcher extends TypeSafeDiagnosingMatcher<Collection<? extends T>> { @Factory public static <T> Matcher<Collection<? extends T>> hasSameItemsAsCollection(Collection<? extends T> correctList) { return new HasSameItemsAsCollectionMatcher<>(correctList); } HasSameItemsAsCollectionMatc...
### Question: HasTextMatcher extends TypeSafeMatcher<WebDriver> { @Factory public static Matcher<WebDriver> textOnCurrentPageContains(String text) { return textOnCurrentPage(CoreMatchers.containsString(text)); } protected HasTextMatcher(Matcher<String> matcher); @Override void describeTo(Description description); @Fac...
### Question: CanFindElementMatcher extends TypeSafeMatcher<WebDriver> { @Factory public static Matcher<WebDriver> canFindElement(By by) { return new CanFindElementMatcher(by); } protected CanFindElementMatcher(By by); @Override void describeTo(Description description); @Factory static Matcher<WebDriver> canFindElemen...