Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
2 answers
101 views

simple Text Table utility

A small utility to print data in an ascii table TextTable ...
Martin Frank's user avatar
  • 3,001
2 votes
1 answer
576 views

Basic Ticket booking code with Unit tests

I am going to run a session for a few other developers who are new to Junit, mocking, etc. I have designed a very simple application with classes and tests to demonstrate how to do unit testing. ...
HariHaravelan's user avatar
0 votes
1 answer
95 views

First time writing tests (Service Layer)

Service class: ...
GodLike's user avatar
  • 51
1 vote
1 answer
94 views

A simple Java integer integer hash set - follow-up 2

(See the previous version.) Now I have this: com.github.coderodde.util.IntHashSet: ...
coderodde's user avatar
  • 29.8k
6 votes
4 answers
1k views

A simple Java integer hash set

(See the next version.) The following data structure implements a hash table based set for int values: ...
coderodde's user avatar
  • 29.8k
5 votes
2 answers
499 views

Hungarian algorithm for optimal assignment

The assignment problem is about assigning tasks to workers, where each pair (worker, task) has a cost. The Hungarian algorithm builds an optimal solution for this problem. It has two variants, ...
Anab's user avatar
  • 385
0 votes
1 answer
57 views

Faster, indexed, heuristic doubly-linked list data structure in Java: unit tests

Here I have the unit tests for the indexed doubly-linked list. It goes like this: ...
coderodde's user avatar
  • 29.8k
3 votes
1 answer
1k views

Testing DAO Delete User

I have several Dao classes, including a UserDao, below. The DAOs have many methods, but I'm focussing on deleteUser: ...
DozezQuest's user avatar
0 votes
1 answer
422 views

Unit tests for User class with JUnit 5

This is a follow-up question for Android app class serialization. Some problems have been mentioned in forsvarir's answer. Then, I am following JUnit 5 User Guide to redesign the test cases for ...
JimmyHu's user avatar
  • 5,510
2 votes
1 answer
99 views

Android app class serialization

I am attempting to build an Android APP with the custom serializable class User. The public method Save is to save class ...
JimmyHu's user avatar
  • 5,510
0 votes
2 answers
1k views

Need Feedback on JUnit test comparing two timestamps

I am writng a JUnit test case for the below methods : ...
user3254725's user avatar
3 votes
2 answers
302 views

Replace words from a file with words from a dictionary based file

I'm working on a coding challenge that tasks me with taking a file with a dictionary, reading from it, and then replacing the matching words from the input file with what is found in the dictionary. I ...
apex's user avatar
  • 33
1 vote
1 answer
89 views

What to test on a rest API?

I created a rest controller with Spring Boot, I am trying to learn what I should write on my tests, right now I only check status codes and keys existence. I am planning to build an API to showcase at ...
Daniel Burgos's user avatar
1 vote
1 answer
174 views

Binary Search recursive & iterative solution

I have implemented binary search solution by using recursion and iterative approach. I there any way to improve it? Tests ...
Neslihan Bozer's user avatar
4 votes
2 answers
241 views

Sanity check a simple RPG character

I'm writing an assistant for the tabletop RPG Pathfinder in Java. I intend to use the MVVM pattern using JavaFX, possibly through mvvmFX. Before I go into the V-VM phase, I have built a first ...
Anab's user avatar
  • 385
3 votes
2 answers
500 views

Unit testing Roman-Arabic-Roman numeric converter

As you can see here, I wrote the methods public static int romanToArabic(String number) and ...
user avatar
-1 votes
1 answer
55 views

Possible Test Cases in Tester [closed]

I am trying to write a human-readable tester for a functioning program. There are four methods in the class Polynomial: ...
Roozilla's user avatar
14 votes
4 answers
3k views

Unit testing Video Service class

I wrote my first unit testing code on a service class using Mockito. The code looks like this: ...
Patrick's user avatar
  • 341
4 votes
4 answers
148 views

Statistics Library with Sample, SampleBuilder and Tests

Introduction I'm working on a Statistics Library that can record observations and produce a Summary of the statistics when there's enough observations. Right now, it's at its early stages and is ...
Hungry Blue Dev's user avatar
9 votes
4 answers
4k views

Building string with max length

I need to run a evaluation for large (1 Million) number of components and build a string with error which has comma separated error codes. As the final string is to be persisted in RDBMS TABLE.COLUMN ...
DKG's user avatar
  • 195
12 votes
4 answers
5k views

Binary Search given sorted array Unit test

I have implemented Binary search code for a given sorted array, written unit test too, Please review my BST unit test code and let me know your comments for improvements. ...
ganesh r's user avatar
  • 185
5 votes
3 answers
3k views

Mars Rover technical Challenge in OOP

I am trying to practice OOP and TDD concepts, I have written this code for Mars rover challenge from marsrovertechchallenge . Can you please review my code from my GitHub repository? Or you can ...
Sara Elmenshawy's user avatar
1 vote
2 answers
434 views

Unit Test BST in Java

I have written BST in Java for practice. How can I write better unit test cases. I am sure the way I have written them is not proper. Code for BST ...
ganesh r's user avatar
  • 185
2 votes
3 answers
3k views

Unit tests code for a Java class that that checks whether an array is sorted

I'm trying to write unit tests code for a java class. The class tests an array for sorted (either way) or not. Here is the Unit Tests code: ...
User_67128's user avatar
2 votes
1 answer
822 views

A simple priority queue in Java via linked list sorted by priority keys

Now I have this very simple priority queue. add and changePriority both run in \$\mathcal{O}(n)\$ and ...
coderodde's user avatar
  • 29.8k
4 votes
2 answers
117 views

Ensure difference between sets

An endpoint that my application interacts with allows you to specify which fields are returned in the JSON result. My application will then map the JSON to a POJO using Jackson. Quite often I add more ...
Michael Ziluck's user avatar
3 votes
2 answers
893 views

Bowling Kata in Java

I am sharing my Bowling Game Score Kata made in Java, it is available for whoever wants to code review it. I appreciate any comments. ...
Michel Dambros Figueiredo's user avatar
3 votes
1 answer
170 views

Non-testable class wrapping Java Properties with basic logic

I have written a simple java.util.Properties wrapping class. Unfortunately, in my opinion, it isn't testable at the moment and I don't have any idea how to improve ...
franiis's user avatar
  • 133
1 vote
1 answer
154 views

Abstracting getter and setter method references for testing

Is the following code easy to understand? If not how should it be changed to be more understandable. The purpose of this is reducing similar code in unit tests. This avoids repeating lines for calling ...
user3624390's user avatar
2 votes
1 answer
812 views

Android Java Unit Testing model class

I'm trying to get familiar with unit testing. I never implement TDD previously, but I believe it's the best way to write software. So, here I'm trying to test my ...
Seto's user avatar
  • 123
1 vote
2 answers
71 views

Two BDD unit tests for an account repository with identical code

I am testing my repository class: interface AccountRepository{ void save(Account account); Optional<Account> findById(Long id); } And when writing ...
Sam's user avatar
  • 179
4 votes
2 answers
4k views

Calculate arithmetic expression represented by a string, in Java

I saw that interview question online and gave it a try: Implement a function that gets a string which represents an arithmethic expression: contains only numbers or the the operators: '+', '-', '*', '/...
John's user avatar
  • 213
1 vote
1 answer
390 views

Testing a service that makes database calls, without a database

I'm working on a new service, for the past year I haven't needed to write tests from scratch. I've either been bug fixing, or adding features that require modification of tests, but not writing ...
mal's user avatar
  • 313
2 votes
1 answer
48 views

Testing a probabilistic prime-testing algorithm that may fail

I have implemented Pollard's Rho algorithm in Java. Due to the nature of it there is a small chance for it to fail (have not seen it happening yet). Since I do not ...
Navarro's user avatar
  • 165
3 votes
1 answer
273 views

Unit Testing for Spring Controller

This is my first attempt to do unit test for one of my controllers. ...
abiieez's user avatar
  • 133
4 votes
3 answers
86 views

Print the first, last, and in-between integers of a range

Given our spec from Code Golf: Given two integers, output the two integers, and then the range between them. The order of the range must be the same as the input. Examples: ...
Marco Tulio Avila Cerón's user avatar
0 votes
1 answer
1k views

Assert LinkedHashMap element in jUnit test [closed]

So I have some test, maybe the given side of that test is not so important to catch the point of my confusion. I wrote ...
shutdown -h now's user avatar
2 votes
1 answer
1k views

Retry Class in Java

I have the following Java code used to retry a certain actions/methods ...
MoonKnight's user avatar
4 votes
1 answer
7k views

Unit test for class converting between DTOs and entities

Is this correctly written test? Tested class is responsible for converting from dto to entity class and i wanted to test it. Are these tests useful and well designed? I have a problem understanding ...
mmprogr's user avatar
  • 41
6 votes
3 answers
3k views

Reverse Polish Notation calculator with unit tests

I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours. Task was programming Reverse Polish ...
gungor's user avatar
  • 173
4 votes
3 answers
925 views

Fizz Buzz Test Driven Development

Task: Create the Fizz Buzz game using Test Driven Developoment. Print the correct word for range 1-100. The implementation: ...
Matthias Herrmann's user avatar
0 votes
1 answer
50 views

Unit Testing Android Studio

I am carrying out unit testing for my project but i am not sure i am doing it correctly. The example below calculates the difference between 2 time duration's. ...
James Ferry's user avatar
2 votes
0 answers
348 views

Unit/Integration Tests for Maven plugin that creates Skipper packages

I am writing an extension to a maven mojo (spring-cloud-skipper-maven-plugin) and I am now writing tests that interact with a skipper server. However, getting the ...
Menelaos's user avatar
  • 251
9 votes
2 answers
1k views

Implementation of Viterbi algorithm along with unit tests

Introduction to the Algorithm A system can be in N different, unobservable states, (i.e, we never know in which state the system actually is). The system also has a finite number of possible ...
Attilio's user avatar
  • 1,645
3 votes
3 answers
450 views

A tiny Java library for generating Gray codes

This library is for generating Gray codes. A Gray code over \$n\$ bits is a list of \$2^n\$ different \$n\$-bit strings subject to the following constraint: two adjacent bit string differ in only one ...
coderodde's user avatar
  • 29.8k
1 vote
1 answer
85 views

Design of genetic algorithm which would allow TDD

I'm implementing genetic algorithm in Java and I want to learn TDD with this project. Currently I have this code: ...
Jump3r's user avatar
  • 175
6 votes
1 answer
116 views

Benchmarking efficient inversion counting algorithms in Java

Given an array \$A = (a_1, a_2, \dots, a_n)\$, the number of inversions in \$A\$ is the number of index pairs \$i,j\$ (\$i < j\$) such that \$a_i > a_j\$. We can find the number of inversions in ...
coderodde's user avatar
  • 29.8k
2 votes
1 answer
1k views

Bidirectional hash map in Java

I have this bidirectional hash map that allows not just accessing values via keys, but also accessing keys via values. You can find a figure explaining the data structure in this post: Bidirectional ...
coderodde's user avatar
  • 29.8k
2 votes
0 answers
676 views

A fast integer key map in Java via a van Emde Boas tree

Introduction The following data structure is a dictionary mapping primitive int values to any value type. Basically, under the hood it is a hash table, where a ...
coderodde's user avatar
  • 29.8k
1 vote
1 answer
890 views

Generic trie implementation in Java

I implemented a Trie data structure in Java, to test my understanding of the concept. I tried (pun intended :) ) to follow TDD steps along the way (i.e., add first a failing test case, and implement ...
Attilio's user avatar
  • 1,645