This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 103183 - Create JUnit tests drops parameterized types (generics)
Summary: Create JUnit tests drops parameterized types (generics)
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marian Petras
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-02 22:35 UTC by Torbjorn Norbye
Modified: 2007-10-08 15:21 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2007-05-02 22:35:21 UTC
Create a class with a method like this

    public List<Foo> getWhatever() {
        return null;
    }

Then do Tools | Create Unit Tests, I choose junit 4.x but possibly 3.x has the problem.

This will create a unit test skeleton for me. but, the test method for getWhatever looses the 
parameterized type!

It does

    List expected = null

rather than
 
    List<Foo> expected = null
Comment 1 Marian Petras 2007-08-03 20:12:20 UTC
Confirmed.
Comment 2 Marian Petras 2007-09-10 17:59:27 UTC
Partially fixed (in the trunk).

It will work now with the exception of parametrized types having at least one type parametrized
(e.g. List<Map.Entry<String,Object>>). This is a shortage caused by bug #105176.

This partial fix will go into NB 6.0 Beta 2.

Modified file:
    junit/src/org/netbeans/modules/junit/AbstractTestGenerator.java   (1.3)

Diff:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/AbstractTestGenerator.java?r1=1.2&r2=1.3&diff_format=u
Comment 3 Marian Petras 2007-10-08 14:06:35 UTC
Fixed in the trunk.

Now that bug #115176 was fixed, I could make a proper fix of this bug.

Modified file:
    junit/src/org/netbeans/modules/junit/AbstractTestGenerator.java   (1.12)

Diff:
http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/src/org/netbeans/modules/junit/AbstractTestGenerator.java?r1=1.11&r2=1.12
Comment 4 Marian Petras 2007-10-08 15:21:26 UTC
I just integrated a very simple fix of this issue - it is a one-line fix which effectively replaces all the other code
modifications mentioned in this bug report. The following patch removes the complex private method and replaces it with
a simple call of TreeMaker.Type(TypeMirror).

http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/src/org/netbeans/modules/junit/AbstractTestGenerator.java?r1=1.13&r2=1.14