I'm in trouble with Jhipster's test packages. I was wondering if I could disable them, even if I know it's better to fix them.
In any case, I show you my problem, I hope to receive some help to fix this.
I've just finished to code a Jhipster webapp. I ran the application in test mode, using main() class. All seem to work perfectly, but when I try to build it I get 12 failed tests and 1 error.
Stacktrace:
Failed tests:
DeskResourceIntTest.createDesk:113 Status expected:<201> but was:<500>
DeskResourceIntTest.deleteDesk:234 Status expected:<200> but was:<500>
DeskResourceIntTest.updateDesk:196 Status expected:<200> but was:<500>
DeskResourceIntTest.updateNonExistingDesk:217 Status expected:<201> but was:<500>
EventResourceIntTest.createEvent:111 Status expected:<201> but was:<500>
EventResourceIntTest.deleteEvent:238 Status expected:<200> but was:<500>
EventResourceIntTest.updateEvent:199 Status expected:<200> but was:<500>
EventResourceIntTest.updateNonExistingEvent:221 Status expected:<201> but was:<500>
UserResourceIntTest.createUser:170 Status expected:<201> but was:<500>
UserResourceIntTest.deleteUser:521 Status expected:<200> but was:<500>
UserResourceIntTest.updateUser:365 Status expected:<200> but was:<500>
UserResourceIntTest.updateUserLogin:409 Status expected:<200> but was:<500>
Tests in error:
CustomUserResourceIntTest.initializationError » Test class should have exactl...
Tests run: 146, Failures: 12, Errors: 1, Skipped: 0
I obviously edited jhipster's generated classes, but at this point I don't know how to fix these problems to finally build and complete my app.
All failed tests fail at this code line:
restUserMockMvc.perform(put("/api/users")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(managedUserVM)))
.andExpect(status().isOk());
This is the situation for 12 failed tests, the method that throws the error is .andExpect().
I edited CustomUserResource.java's constructor in this mode:
public CustomUserResource(CustomUserRepository customUserRepository,
UserRepository userRepository, UserService userService,
PasswordEncoder passwordEncoder, DeskRepository deskRepository, EventRepository eventRepository) {
this.customUserRepository = customUserRepository;
this.userRepository = userRepository;
this.userService = userService;
this.passwordEncoder = passwordEncoder;
this.deskRepository = deskRepository;
this.eventRepository = eventRepository;
}
The same is CustomUserResourceIntTest.java:
public CustomUserResourceIntTest(CustomUserRepository customUserRepository, UserRepository userRepository,
UserService userService, PasswordEncoder passwordEncoder,
DeskRepository deskRepository, EventRepository eventRepository) {
this.customUserRepository = customUserRepository;
this.userRepository = userRepository;
this.userService = userService;
this.passwordEncoder = passwordEncoder;
this.deskRepository = deskRepository;
this.eventRepository = eventRepository;
}
The code line that throws error is this one:
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
CustomUserResource customUserResource = new CustomUserResource(customUserRepository, userRepository, userService,
passwordEncoder, deskRepository, eventRepository);
this.restCustomUserMockMvc = MockMvcBuilders.standaloneSetup(customUserResource)
.setCustomArgumentResolvers(pageableArgumentResolver)
.setControllerAdvice(exceptionTranslator)
.setMessageConverters(jacksonMessageConverter).build();
}
Aucun commentaire:
Enregistrer un commentaire