Skip to main content

r/learnjava


Unit Testing with JUnit and Mockito in SpringBoot
Unit Testing with JUnit and Mockito in SpringBoot

So I am learning Spring Boot and reached testing, while learning testing specifically Unit Testing with JUnit and Mockito, I realized that I would need to create a unit test or function for every method and create reach Happy Path (Everything goes right) and Negative Path (Something went wrong). While trying to create my own testing I realized that it would take up too much of my time to create unit tests for all my methods from my project.

My question is does companies that uses Spring Boot requires creating Unit Testing for the entire project?. What if the project is too big wouldn't it take up so much time and might delay shipping of features?.

I also want to ask if its okay if we ask AI to those unit testing instead. Since AI is much faster than writing the code for testing manually.

//DISABLE ACCOUNT (ACCOUNT ALREADY DISABLED)
u/Test
void shouldThrowExceptionWhenUserIsAlreadyDisabled(){
    //ARRANGE
    Roles fakeRole = new Roles();
    fakeRole.setRoleName("Frontdesk");

    Users fakeUser = new Users();
    fakeUser.setFirstName("John");
    fakeUser.setLastName("Doe");
    fakeUser.setRole(fakeRole);
    fakeUser.setAccountStatus(AccountStatus.
Disabled
);
    
when
(usersRepository.findById(1)).thenReturn(Optional.
of
(fakeUser));

    //ACT + ASSERT
    
assertThrows
(NoChangesDetected.class, () -> {
        usersService.disableAccount(1);
    });
}

Prompt a playlist for absolutely anything.
media poster


Newbie Java Learner: Need advice on the "Right" way to learn for Backend Dev and how to handle getting stuck
Newbie Java Learner: Need advice on the "Right" way to learn for Backend Dev and how to handle getting stuck

​Hey everyone,

​I’m currently learning Java with the goal of becoming a Backend Developer. I'm hitting a few roadblocks and would love some guidance from the experienced folks here:

1- ​The "Right" Path: What is the most effective way to learn Java specifically for backend development? What should I focus on first (Fundamentals, OOP, Spring Boot, etc.)?

2- ​Handling Getting Stuck: Sometimes I face a problem—even a simple one—and my mind just goes completely blank. I have no idea how to approach it. What is the professional way to handle this? How do you guys troubleshoot when you're stuck?

3- ​Building Projects: I want to start building small projects on my own to practice, but I don't know where to start or how to structure my practice. Any advice on how to move from tutorials to building independently?

Note: I'm currently taking a course on Udemy. I have already finished the fundamentals (variables, loops, conditions, etc.) and I'm just about to dive into Object-Oriented Programming (OOP)

​I’d really appreciate any tips, resources, or "rules of thumb" you follow. Thanks in advance


How to switch from Monitoring & Support role to Java Developer role?
How to switch from Monitoring & Support role to Java Developer role?

Hi everyone,

I have 2.5 YOE in SAP OCC - System monitoring role. While I have tried multiple times to switch internally to developer role inside SAP, it is less and less useful due to bureaucracy in MNC. I am looking to switch to Java backend development.

My reasons to consider Java Backend -

  1. I have basic knowledge of Java so can built on top of that.

  2. I don't want to hit a salary ceiling soon and would love to join product based company asap within 3-4 years.

  3. I find sometimes SAP ecosystem rigid and boring.

Has anyone done like this before? If yes, please guide a little. Even a little information or advice would be helpful for me.

On a high level, my queries are -

  1. Is it nearly impossible for me to switch now?

  2. While my current CTC is 7 LPA, will it take a pay cut?

  3. Should I stay in SAP and try moving in SAP ABAP or Fiori better than Java Backend?