Questions tagged [private-methods]

285 questions
0
votes
1 answer

junit for multi threaded class with mockito

Please, help me write a JUnit test for this code using Mockito. class A{ private BlockingQueue jobQueue; public void methodA(List messages) { try { jobQueue.put(() -> methodB(message)); }…
dom cobb
  • 25
  • 1
  • 5
0
votes
1 answer

Inheritance of a private method and Late Static Binding in php

So I've been reading official PHP documentation on Late Static Bindings and came across a confusing example: foo(); …
0
votes
2 answers

Refactoring between public and private methods in Python

I'm looking at the Binary Search Trees section in the tutorial "Problem Solving with Algorithms and Data Structures", (http://interactivepython.org/runestone/static/pythonds/Trees/SearchTreeImplementation.html). On several occasions, they use…
sammy
  • 857
  • 5
  • 13
0
votes
1 answer

How to use a method in a class for error catching in Python?

I have written a class to simulate the throw of a dice. I am trying to implement the private method __check_dice(self) to catch errors when creating an instance of the class to avoid code duplication: import numpy as np class Dice(): """…
gxpr
  • 836
  • 9
  • 12
0
votes
0 answers

How can I swap the element at index0 of an ArrayList with another element if the index of that element is found through a private method? (Java)

I'm trying to make a card game where one of the moves a player can take is a swap option, wherein it takes the card in play (the element at index0 of an ArrayList) and swaps it with another. The index of that other card is found through a private…
user8638151
  • 21
  • 1
  • 7
0
votes
1 answer

Got IllegalStateException while mocking private method of class under test using Expectations by jmockit

I'm using jmockit-1.26 to mock private methods of class under test. I've succeed to mock these methods by MockUp. But it is more complicated then Expectations. I'm try to use Expectations to do this. But I got IllegalStateException while running the…
0
votes
2 answers

Why do I get a Reflection exception NoSuchMethodException if the tests runs fine

I'm using Reflection to Mock a private method (I don't want to discuss if that makes sense or not). Anyone know why? I'll let my testClass source code here it may help. I've tryed much of the Internet helps and ways to solve this but none have…
R.Quintal
  • 43
  • 1
  • 3
  • 13
0
votes
1 answer

JavaScript: multiple instances wrong reference to private property

In the fiddle is a "class" I have written to manage navigation over the data model and a test which shows that multiple instances (starting from second) of this "class" are referencing something wrong. https://jsfiddle.net/btvmnaxc/ (outputs to…
0
votes
2 answers

Why are the values still adding up after i clear the output label?

I'm not sure what is going on. I thought I had it set up to clear the output label at the end. Everytime I clear it, the program still remembers the previous number and adds to it. I honestly have no idea what is going on. Also on a side note, how…
D. Kon
  • 1
0
votes
2 answers

Nunit Test - To test a part of private method code that is being called by public method

I'm trying to test a piece of code in a private method(Method A). In the flow this private method is being called by a public method. In order to test this code in method A. It returns data from another private method(method B) public returntype…
joy
  • 3
  • 5
0
votes
1 answer

Public/private moethod declaration-only on ES6 classes with babel

I'm using Babel with default es2015 preset to convert ES6 JS code. Since I'm working in another project with TypeScript, I've come to appreciate the publi/private annotation on methods. I'd like to use the same annotation in JS code. Even if it…
don
  • 4,113
  • 13
  • 45
  • 70
0
votes
1 answer

Why is a private method always called when a global method with same name exists in JavaScript?

I have some sample code in JavaScript as below. When the button is clicked then the private method by the name of doSomething of object xyz is always called, even though a method of same name exists at the global level. I am trying to understand…
Sunil
  • 20,653
  • 28
  • 112
  • 197
0
votes
1 answer

$.fn.myPlugin vs $.something.myPlugin in regard to private and public methods

So I can't seem to find astraight answer on this, only vague examples of multiple variations where similar plugin/method declarations are used. I know that by saying $.fn.myPlugin I am defining a publicly available plugin method that can be…
0
votes
2 answers

Confusing example of Private V.S. Public method in book ?

I've been reading Javascript Patterns by Stefanov recently. And I found this example confusing to me here: Another case of using a convention to mimic functionality is the private members >con- vention. Although you can implement true privacy in…
0
votes
1 answer

Rails accessing private methods using attr_encrypted

I'm trying to get attr_encrypted to obscure some data before saving it to the database. I need to deal with the logger output later, but at the moment I just want to get the field data from a submitted form, encrypt it, and save it. Here's my…
DanielNordby
  • 569
  • 2
  • 6
  • 20