Instantiating a class without constructor and with @Value annotation for Junit

I want to make a Bean in context of my Junit code of a spring web application. Here is the class in the project that i want to instantiate.
This has no constructor and also uses @Value annotation. How to do it.

public class AppEnvironment {

    private String appId;
    private String appSecret;
    private boolean isProd;
    private String baseUrl;
    private String botGUID;
    private String botToken;
    private String appIconUrl;
    private String fontColor;
    private String reminderBotHost;

Open in new window

Rohit BajajAsked:
Who is Participating?
girionisConnect With a Mentor Commented:
There are several approaches:

1) Mock the class (using Mockito/JMock/any other mocking framework)
2) Run it with SpringJUnit4ClassRunner and use a @TestPropertySource
3) Change the access to package and set the values manually.
This is a perfectly valid answer.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.