Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PODAM fails to initialize MyType<T> containing final Map<T,T> #247

Closed
JordanAngold opened this issue Aug 16, 2017 · 4 comments
Closed

PODAM fails to initialize MyType<T> containing final Map<T,T> #247

JordanAngold opened this issue Aug 16, 2017 · 4 comments
Assignees
Labels

Comments

@JordanAngold
Copy link

I have a test case that requires PODAM to create and fill a POJO containing a final Map<T,T> as suggested in the title, and found that it doesn't work. I'm using PODAM 7.0.5 .

I have distilled the problem down to this example:

public class MyTest {
	@Test
	public void test() {
		PodamFactory factory = new PodamFactoryImpl();
		MyType<String> wrapper = factory.manufacturePojoWithFullData(MyType.class, String.class);
		assertNotNull(wrapper);
	}

	public static class MyType<T> {
		/* // works:
		Map<T,T> map;
		public void setMap(Map<T,T> map) { this.map = map; }
		//*/

		// doesn't work:
		final Map<T,T> map = new HashMap<>();

		public Map<T,T> getMap() {
			return map;
		}
	}
}

If you use the 'doesn't work' part, you get:

java.lang.IllegalArgumentException: java.util.Map is missing generic type arguments, expected [K, V], provided [T, T]
	at uk.co.jemos.podam.typeManufacturers.TypeManufacturerUtil.fillTypeArgMap(TypeManufacturerUtil.java:169)
	at uk.co.jemos.podam.api.PodamFactoryImpl.populateReadOnlyField(PodamFactoryImpl.java:709)
	at uk.co.jemos.podam.api.PodamFactoryImpl.populatePojoInternal(PodamFactoryImpl.java:622)
	at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoInternal(PodamFactoryImpl.java:533)
	at uk.co.jemos.podam.api.PodamFactoryImpl.doManufacturePojo(PodamFactoryImpl.java:436)
	at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoWithFullData(PodamFactoryImpl.java:141)
	at MyTest.test:15

If you instead use the 'works' part instead, then you get a correctly-constructed object.

@daivanov daivanov self-assigned this Aug 21, 2017
@daivanov daivanov added the Bug label Aug 21, 2017
daivanov added a commit to daivanov/joinmo that referenced this issue Aug 21, 2017
@daivanov
Copy link
Collaborator

@JordanAngold
Copy link
Author

Thank you for your swift response. I spent some time testing 7.1.1 and it seems to have fixed the issue I described above.

Unfortunately, the test I am working with is brittle and breaks for a number of other reasons with 7.1.1 (as compared to 7.0.5). I haven't been able to do a full analysis of the cause, but it could be anything between those versions -- I have no particular reason to believe that it's 7.1.1 itself.

I don't know when I will get more time to deal with those issues (it certainly won't be for at least a week). I think this ticket can probably be closed, but I will leave that decision up to you.

@daivanov
Copy link
Collaborator

There is also version 7.1.0, which was released some time ago.
You can enable debug log level and this should give you a good hint what is happening in your tests and what could be a root cause for a problems.

@daivanov
Copy link
Collaborator

Let's close this issue. Fixed in Podam 7.1.1 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants