{"action":"opened","issue":{"url":"https://api.github.com/repos/jayway/powermock/issues/372","labels_url":"https://api.github.com/repos/jayway/powermock/issues/372/labels{/name}","comments_url":"https://api.github.com/repos/jayway/powermock/issues/372/comments","events_url":"https://api.github.com/repos/jayway/powermock/issues/372/events","html_url":"https://github.com/jayway/powermock/issues/372","id":97066848,"number":372,"title":"Mocking of New with array argument","user":{"login":"johanhaleby","id":187029,"avatar_url":"https://avatars.githubusercontent.com/u/187029?v=3","gravatar_id":"","url":"https://api.github.com/users/johanhaleby","html_url":"https://github.com/johanhaleby","followers_url":"https://api.github.com/users/johanhaleby/followers","following_url":"https://api.github.com/users/johanhaleby/following{/other_user}","gists_url":"https://api.github.com/users/johanhaleby/gists{/gist_id}","starred_url":"https://api.github.com/users/johanhaleby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanhaleby/subscriptions","organizations_url":"https://api.github.com/users/johanhaleby/orgs","repos_url":"https://api.github.com/users/johanhaleby/repos","events_url":"https://api.github.com/users/johanhaleby/events{/privacy}","received_events_url":"https://api.github.com/users/johanhaleby/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jayway/powermock/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/jayway/powermock/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/jayway/powermock/labels/Priority-Medium","name":"Priority-Medium","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-24T14:36:40Z","updated_at":"2015-07-24T14:36:40Z","closed_at":null,"body":"_From [Megafone...@gmail.com](https://code.google.com/u/114638174492000227157/) on October 26, 2011 14:07:21_\n\nI have a clas with the following constructor \r\n\r\n    public Struct(NameValue[] nameValueArray)\r\n    {\r\n        _nvs = nameValueArray;\r\n    }\r\n\r\nthat I want to mock. Problem is that I get Unexpected constructor call. \r\n\r\nFirst I tried expectNew with the class and an array, like this:\r\n\r\nNameValue[] nameValues = new NameValue[] {nameValueMock,nameValueMock,nameValueMock,};\r\nPowerMock.expectNew(Struct.class,nameValues).andReturn(structMock);\r\n\r\nResult: \r\n\r\norg.powermock.reflect.exceptions.ConstructorNotFoundException: No constructor found in class 'se.ericsson.cello.neal.cm.Struct' with parameter types: [ se.ericsson.cello.neal.cm.NameValue, se.ericsson.cello.neal.cm.NameValue, se.ericsson.cello.neal.cm.NameValue ].\r\n\r\nIt seems that each member of the array is treated as an argument.\r\n\r\nThen I tried to eclose my array in another array, like this:\r\n\r\nObject[] container = new Object[] {nameValues};\r\nPowerMock.expectNew(Struct.class, container).andReturn(structMock);\r\n\r\nResult:\r\n\r\njava.lang.AssertionError: \r\n  Unexpected constructor call se.ericsson.cello.neal.cm.Struct([ EasyMock for interface se.ericsson.cello.neal.cm.NameValue, EasyMock for interface se.ericsson.cello.neal.cm.NameValue, EasyMock for interface se.ericsson.cello.neal.cm.NameValue]):\r\n    se.ericsson.cello.neal.cm.Struct([ EasyMock for interface se.ericsson.cello.neal.cm.NameValue, EasyMock for interface se.ericsson.cello.neal.cm.NameValue, EasyMock for interface se.ericsson.cello.neal.cm.NameValue]): expected: 1, actual: 0\r\n\r\nNow, at least, it looks like there is an array sent into the constructor, BUT it still not working.\r\n\r\nWhat shall I do to get it to work?\n\n_Original issue: http://code.google.com/p/powermock/issues/detail?id=352_"}}