You must have the following dependencies, Junit is included, do not add it.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.3</version>
<scope>test</scope>
</dependency>
you must write down the main class:
@SpringBootApplication
public class App
you must write down the class of the tests:
@SpringBootTest
public class IdGeneratorTest {
you must inject the service:
@Autowired
private IdGenerator service;
you can use it like this:
@Test
void testNoRepeated() {
String symbolsOrder = "1234567890";
service.configure(10, symbolsOrder );
You must write down the class you want to convert into a service:
@Service
above:
public class IdGenerator {
services and the main class do not have a constructor
the imports are:
import org.springframework.stereotype.Service;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.autoconfigure.SpringBootApplication;