TRUNK-4256 Inconsistency between inheritedRoles and childRoles of a role

Hi,

I would like to work on this issue - [TRUNK-4256] - OpenMRS Issues

Issue description -

Role anonymous = Context.getUserService().getRole("Anonymous");
Role sysdev = Context.getUserService().getRole("System Developer");

anonymous.getChildRoles().add(sysdev);
sysdev.getInheritedRoles().add(anonymous); 

Context.getUserService().saveRole(anonymous);
Context.getUserService().saveRole(sysdev);

Context.flushSession();

You get “Unique index or primary key violation” as it tries to put the relationship twice into role_role.

I would actually expect that when you call sysdev.getInheritedRoles().add(anonymous); then it should call anonymous.getChildRoles().add(sysdev); to maintain consistency


Here I couldn’t understand the scene behind this following text,

You get “Unique index or primary key violation” as it tries to put the relationship twice into role_role.

It would be really helpful, if some body guide to understand this description?

Thanks.

Since this was written a couple of years ago, there is a possibility that it was fixed. Can you first of all create a unit test reproducing it on the latest snapshot of openmrs core?

Hi @dkayiwa

The issue mentioned above does not exist in the system right now. I have added the test case to ensure that problem is solved. I have sent a PR to OpenMRS Core with a test case.

Please find the PR here : https://github.com/openmrs/openmrs-core/pull/2626

Thanks.

Do you have some time to do a sanity check on the 1.9.7 tag of openmrs-core to see if this test fails when run against it?

I have tried to do a sanity check on the 1.9.7 tag with this test cases. But I got an unexpected results due to some other problems. I have attached the logs[1] here.

@dkayiwa Could you please help to resolve this one?

[1] - https://pastebin.com/yQiNsuXT

On which version of Java did you run the 1.9.7 tag?

I have tried with Java version 1.8.

Can you try compile it with Java 7?

Unfortunately, I couldn’t setup my environment with Java 7 right now (I already installed Java 8 in Ubuntu 17.10). Let me find the problem and continue the work.

Thanks