package com.oransc.rappmanager.dme.service;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
@ParameterizedTest
@MethodSource("getSuccessParamsWithUnavailableInfoTypes")
- void testPrimeRappSuccessWithUnavailableInfoType(String rappFile, boolean result) throws JsonProcessingException {
+ void testPrimeRappSuccessWithUnavailableInfoType(String rappFile, boolean isSuccess)
+ throws JsonProcessingException {
RappResources rappResources = rappDmeResourceBuilder.getResources();
Rapp rapp = getRapp(Optional.empty());
rapp.setPackageName(rappFile);
if (rappFile.equals(validRappFileNewInfoType)) {
mockServer.verify();
}
- assertEquals(rapp.getIsDmeValid(), result);
+ if (isSuccess) {
+ assertNull(rapp.getReason());
+ } else {
+ assertNotNull(rapp.getReason());
+ }
}
private static Stream<Arguments> getSuccessParamsWithUnavailableInfoTypes() {
}
@ParameterizedTest
- @MethodSource("getSuccessParamsWithAvailableInfoTypes")
- void testPrimeRappSuccessWithValidInfoType(String rappFile, boolean result) throws JsonProcessingException {
+ @ValueSource(strings = {validRappFile, validRappFileNewInfoType})
+ void testPrimeRappSuccessWithValidInfoType(String rappFile) throws JsonProcessingException {
RappResources rappResources = rappDmeResourceBuilder.getResources();
Rapp rapp = getRapp(Optional.empty());
rapp.setPackageName(rappFile);
if (rappFile.equals(validRappFileNewInfoType)) {
mockServer.verify();
}
- assertEquals(rapp.getIsDmeValid(), result);
- }
-
- private static Stream<Arguments> getSuccessParamsWithAvailableInfoTypes() {
- return Stream.of(Arguments.of(validRappFile, true), Arguments.of(validRappFileNewInfoType, true));
+ assertNull(rapp.getReason());
}
@Test
Rapp rapp = getRapp(Optional.empty());
rapp.setRappResources(rappResources);
assertFalse(dmeDeployer.primeRapp(rapp));
- assertFalse(rapp.getIsDmeValid());
+ assertFalse(rapp.getReason().isEmpty());
}
@Test
void testDeprimeRapp() {
Rapp rapp = getRapp(Optional.empty());
- rapp.setIsDmeValid(true);
assertTrue(dmeDeployer.deprimeRapp(rapp));
- assertNull(rapp.getIsDmeValid());
+ assertNull(rapp.getReason());
}
@Test