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

NLIC-1980: Group models & packages in a license bundle #40

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.labs64.netlicensing.domain.EntityFactory;
import com.labs64.netlicensing.domain.entity.Bundle;
import com.labs64.netlicensing.domain.entity.License;
import com.labs64.netlicensing.domain.vo.BundleObtainParameters;
import com.labs64.netlicensing.domain.vo.Context;
import com.labs64.netlicensing.domain.vo.Page;
import com.labs64.netlicensing.exception.NetLicensingException;
Expand Down Expand Up @@ -120,32 +119,23 @@ public static void delete(final Context context, final String number)
*
* @param context determines the vendor on whose behalf the call is performed
* @param number bundle number
* @param bundleObtainParameters bundle obtain parameters
* @param licenseeNumber licensee number
* @return collection of created licenses.
* @throws NetLicensingException any subclass of {@linkplain NetLicensingException}. These exceptions will be transformed to the
* corresponding service response messages.
*/
public static Page<License> obtain(final Context context, final String number, final BundleObtainParameters bundleObtainParameters)
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber)
throws NetLicensingException {
CheckUtils.paramNotEmpty(number, "number");
CheckUtils.paramNotEmpty(bundleObtainParameters.getLicenseeNumber(), "licenseeNumber");
CheckUtils.paramNotEmpty(licenseeNumber, "licenseeNumber");

final String endpoint = Constants.Bundle.ENDPOINT_PATH + "/" + number + "/" + Constants.Bundle.ENDPOINT_OBTAIN_PATH;

final Form form = convertBundleObtainParameters(bundleObtainParameters);
final Form form = new Form();
form.param(Constants.Licensee.LICENSEE_NUMBER, licenseeNumber);

final Netlicensing response = NetLicensingService.getInstance().request(context, HttpMethod.POST, endpoint, form, null);

return entityFactory.createPage(response, License.class);
}

private static Form convertBundleObtainParameters(final BundleObtainParameters bundleObtainParameters) {
final Form form = new Form();

if (bundleObtainParameters != null) {
form.param(Constants.Licensee.LICENSEE_NUMBER, bundleObtainParameters.getLicenseeNumber());
}

return form;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.labs64.netlicensing.domain.entity.Bundle;
import com.labs64.netlicensing.domain.entity.License;
import com.labs64.netlicensing.domain.entity.impl.BundleImpl;
import com.labs64.netlicensing.domain.vo.BundleObtainParameters;
import com.labs64.netlicensing.domain.vo.Context;
import com.labs64.netlicensing.domain.vo.Currency;
import com.labs64.netlicensing.domain.vo.Page;
Expand Down Expand Up @@ -219,19 +218,14 @@ public void testDelete() throws Exception {

@Test
public void testObtain() throws Exception {
final BundleObtainParameters bundleObtainParameters = new BundleObtainParameters();
bundleObtainParameters.setLicenseeNumber("LE001-TEST");

final Page<License> licenses = BundleService.obtain(context, "B001-TEST", bundleObtainParameters);
final Page<License> licenses = BundleService.obtain(context, "B001-TEST", "LE001-TEST");

assertNotNull(licenses);
assertTrue(licenses.hasContent());
assertEquals(3, licenses.getItemsNumber());

final Exception e = assertThrows(ServiceException.class, () -> {
final BundleObtainParameters bundleObtainParameters2 = new BundleObtainParameters();
bundleObtainParameters2.setLicenseeNumber("LE002-TEST");
BundleService.obtain(context, "B001-TEST", bundleObtainParameters2);
BundleService.obtain(context, "B001-TEST", "LE002-TEST");
});
assertEquals("NotFoundException: Requested licensee does not exist.", e.getMessage());
}
Expand Down Expand Up @@ -285,7 +279,7 @@ public Response obtain(@PathParam("number") final String number,
}

final String xmlResourcePath = String.format("%snetlicensing-bundle-obtain.xml", TEST_CASE_BASE);

final Netlicensing netlicensing = JAXBUtils.readObject(xmlResourcePath, Netlicensing.class);
return Response.ok(netlicensing).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public Response validateLicensee(@PathParam("licenseeNumber") final String licen
*
* @param licenseeNumber
* licensee number
* @param transfer
* @param transferLicensee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire method signature of this mock is incorrect, and it works solely because the 'transferLicensee' parameter is unused, thus eluding test coverage, which is the actual problem. Therefore, this suggested javadoc revision seems pointless.

* transfer licensee number
* @return response with XML representation of transfer result
*/
Expand Down
Loading