Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vishwasbabu/95a24bd5d087831c253f to your computer and use it in GitHub Desktop.
Save vishwasbabu/95a24bd5d087831c253f to your computer and use it in GitHub Desktop.
Unit Tests on MifosX
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ServerApplication.Configuration.class)
@WebAppConfiguration
@IntegrationTest({ "server.port=0", "management.port=0", "mariaDB4j.port=0", "mariaDB4j.dataDir=null" })
public abstract class AbstractSpringBootWithDatabaseIntegrationTest {
// do NOT put any helper methods here!
// it's much better to use composition instead of inheritance
// so write a test util ("fixture") and use it as a field in your test
}
public class SpringBootServerLoginTest extends AbstractSpringBootWithDatabaseIntegrationTest {
protected RestAssuredFixture util;
@Autowired
private ClientRepositoryWrapper clientRepositoryWrapper;
@Autowired
private AppUserRepository userRepository;
@Autowired
private BasicAuthTenantDetailsService basicAuthTenantDetailsService;
@Test
// @Ignore("Failing on Cloubees")
public void hasMifosPlatformStarted() {
// util = new RestAssuredFixture(8443);
//List<Map<String, String>> response = util.httpGet("/users");
//assertThat(response.get(0).get("username"), is("adama"));
//System.out.println("Lets create a Client");
final MifosPlatformTenant tenant = this.basicAuthTenantDetailsService.loadTenantById("default");
ThreadLocalContextUtil.setTenant(tenant);
List<AppUser> allUsers = this.userRepository.findAll();
for (AppUser appUser : allUsers) {
System.out.println(appUser.getUsername());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment