@@ -174,6 +174,31 @@ public void testValidate() throws Exception {
174174 .get (Constants .ValidationResult .WARNING_LEVEL ).getValue ()));
175175 }
176176
177+ @ Test
178+ public void testOfflineValidation () throws Exception {
179+ final ValidationParameters validationParameters = new ValidationParameters ();
180+ validationParameters .setLicenseeName ("Test Licensee" );
181+ validationParameters .setProductNumber (productNumber );
182+ validationParameters .setLicenseeProperty ("customProperty" , "Licensee Custom Property" );
183+ validationParameters .setForOfflineUse (true );
184+ final ValidationResult result = LicenseeService .validate (context , licenseeNumber , validationParameters );
185+
186+ assertEquals (licenseeNumber , result .getLicensee ().getNumber ());
187+
188+ final Composition validation = result .getProductModuleValidation ("M001-TEST" );
189+ assertNotNull (validation );
190+ assertEquals ("FeatureWithTimeVolume" , validation .getProperties ().get (Constants .ProductModule .LICENSING_MODEL )
191+ .getValue ());
192+ assertEquals ("Test module" , validation .getProperties ().get (Constants .ProductModule .PRODUCT_MODULE_NAME )
193+ .getValue ());
194+ assertTrue (Boolean .parseBoolean (validation .getProperties ().get ("LIST1" ).getProperties ()
195+ .get (Constants .LicensingModel .VALID ).getValue ()));
196+ assertEquals (
197+ WarningLevel .GREEN ,
198+ WarningLevel .parseString (validation .getProperties ().get ("LIST2" ).getProperties ()
199+ .get (Constants .ValidationResult .WARNING_LEVEL ).getValue ()));
200+ }
201+
177202 @ Test
178203 public void testTransfer () throws Exception {
179204 final String sourceLicenseeNumber = "L002-TEST" ;
@@ -239,7 +264,8 @@ public Response delete(final String licenseeNumber, final UriInfo uriInfo) {
239264 public Response validateLicensee (@ PathParam ("licenseeNumber" ) final String licenseeNumber ,
240265 @ FormParam ("productNumber" ) final String productNumber ,
241266 @ FormParam ("licenseeName" ) final String licenseeName ,
242- @ FormParam ("customProperty" ) final String licenseeCustomProperty ) {
267+ @ FormParam ("customProperty" ) final String licenseeCustomProperty ,
268+ @ FormParam ("forOfflineUse" ) final String forOfflineUse ) {
243269
244270 if (!productNumber .equals (productNumber )) {
245271 return unexpectedValueErrorResponse ("productNumber" );
@@ -252,8 +278,12 @@ public Response validateLicensee(@PathParam("licenseeNumber") final String licen
252278 return unexpectedValueErrorResponse ("customProperty" );
253279 }
254280
281+ final String validationFile = (Boolean .parseBoolean (forOfflineUse ))
282+ ? "netlicensing-licensee-validate-offline.xml"
283+ : "netlicensing-licensee-validate.xml" ;
284+
255285 final Netlicensing netlicensing = JAXBUtils .readObject (TEST_CASE_BASE
256- + "netlicensing-licensee-validate.xml" , Netlicensing .class );
286+ + validationFile , Netlicensing .class );
257287 return Response .ok (netlicensing ).build ();
258288 }
259289
0 commit comments