How to use isNullable method of org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue class

Best EvoMaster code snippet using org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue.isNullable

Source:ExampleBuilderTest.java Github

copy

Full Screen

...121 for (NamedTypedValue p : ((ObjectParam)p1).getType().getFields()){122 assertTrue(p instanceof StringParam);123 StringParam ns = (StringParam) p;124 if (p.getName().equals("longValue")){125 assertTrue(p.isNullable());126 assertFalse(ns.getMaxInclusive());127 assertTrue(ns.getMinInclusive());128 assertEquals(Long.MAX_VALUE, ns.getMax().longValue());129 assertNull(ns.getMin());130 }else if (p.getName().equals("intValue")){131 assertFalse(p.isNullable());132 assertEquals(Integer.MAX_VALUE, ns.getMax().intValue());133 assertFalse(ns.getMaxInclusive());134 assertTrue(ns.getMinInclusive());135 }else if (p.getName().equals("bigIntegerValue")){136 assertTrue(p.isNullable());137 assertEquals(Long.MAX_VALUE, ns.getMax().longValue());138 assertFalse(ns.getMaxInclusive());139 assertTrue(ns.getMinInclusive());140 }else if (p.getName().equals("bigDecimalValue")){141 assertTrue(p.isNullable());142 assertEquals(Double.MAX_VALUE, ns.getMax().doubleValue());143 assertFalse(ns.getMaxInclusive());144 assertEquals(15, ns.getPrecision());145 assertEquals(5, ns.getScale());146 assertFalse(ns.getMinInclusive());147 assertEquals(0.0, ns.getMin().doubleValue());148 }149 }150 }151 @Test152 public void testImmutableObj(){153 EndpointSchema endpoint = getOneEndpoint("immutableObj");154 assertNotNull(endpoint.getResponse());155 assertNotNull(endpoint.getRequestParams());156 assertEquals(1, endpoint.getRequestParams().size());157 NamedTypedValue p1 = endpoint.getRequestParams().get(0);158 assertTrue(p1 instanceof ObjectParam);159 assertEquals(3, ((ObjectParam)p1).getType().getFields().size());160 for (NamedTypedValue p : ((ObjectParam)p1).getType().getFields()){161 assertFalse(p.isMutable());162 if (p.getName().equals("nullLong")){163 assertTrue(p.isNullable());164 assertNull(p.getDefaultValue());165 }else if (p.getName().equals("pbool")){166 assertFalse(p.isNullable());167 assertNotNull(p.getDefaultValue());168 assertTrue(p.getDefaultValue() instanceof BooleanParam);169 assertFalse(((BooleanParam)p.getDefaultValue()).getValue());170 }else if (p.getName().equals("wbool")){171 assertTrue(p.isNullable());172 assertNotNull(p.getDefaultValue());173 assertTrue(p.getDefaultValue() instanceof BooleanParam);174 assertTrue(((BooleanParam)p.getDefaultValue()).getValue());175 }176 }177 }178 @Test179 public void testbigNumber(){180 EndpointSchema endpoint = getOneEndpoint("bigNumber");181 assertNotNull(endpoint.getResponse());182 assertNotNull(endpoint.getRequestParams());183 assertEquals(1, endpoint.getRequestParams().size());184 NamedTypedValue p1 = endpoint.getRequestParams().get(0);185 assertTrue(p1 instanceof ObjectParam);186 assertEquals(8, ((ObjectParam)p1).getType().getFields().size());187 for (NamedTypedValue p : ((ObjectParam)p1).getType().getFields()){188 assertTrue(p instanceof NumericConstraintBase);189 if (p.getName().equals("bdPositiveFloat")){190 assertEquals(4, ((NumericConstraintBase)p).getPrecision());191 assertEquals(2, ((NumericConstraintBase)p).getScale());192 assertEquals("42.42", ((NumericConstraintBase)p).getMax().toString());193 assertEquals("0", ((NumericConstraintBase)p).getMin().toString());194 assertFalse(((NumericConstraintBase) p).getMinInclusive());195 assertTrue(((NumericConstraintBase) p).getMaxInclusive());196 }else if (p.getName().equals("bdPositiveOrZeroFloat")){197 assertEquals(4, ((NumericConstraintBase)p).getPrecision());198 assertEquals(2, ((NumericConstraintBase)p).getScale());199 assertEquals("42.42", ((NumericConstraintBase)p).getMax().toString());200 assertEquals("0", ((NumericConstraintBase)p).getMin().toString());201 assertTrue(((NumericConstraintBase) p).getMinInclusive());202 assertTrue(((NumericConstraintBase) p).getMaxInclusive());203 } else if (p.getName().equals("bdNegativeFloat")){204 assertEquals(4, ((NumericConstraintBase)p).getPrecision());205 assertEquals(2, ((NumericConstraintBase)p).getScale());206 assertEquals("0", ((NumericConstraintBase)p).getMax().toString());207 assertEquals("-42.42", ((NumericConstraintBase)p).getMin().toString());208 assertTrue(((NumericConstraintBase) p).getMinInclusive());209 assertFalse(((NumericConstraintBase) p).getMaxInclusive());210 } else if (p.getName().equals("bdNegativeOrZeroFloat")){211 assertEquals(4, ((NumericConstraintBase)p).getPrecision());212 assertEquals(2, ((NumericConstraintBase)p).getScale());213 assertEquals("0", ((NumericConstraintBase)p).getMax().toString());214 assertEquals("-42.42", ((NumericConstraintBase)p).getMin().toString());215 assertTrue(((NumericConstraintBase) p).getMinInclusive());216 assertTrue(((NumericConstraintBase) p).getMaxInclusive());217 } else if (p.getName().equals("biPositive")){218 assertEquals(2, ((NumericConstraintBase)p).getPrecision());219 assertEquals(0, ((NumericConstraintBase)p).getScale());220 assertEquals("42", ((NumericConstraintBase)p).getMax().toString());221 assertEquals("0", ((NumericConstraintBase)p).getMin().toString());222 assertFalse(((NumericConstraintBase) p).getMinInclusive());223 assertTrue(((NumericConstraintBase) p).getMaxInclusive());224 }else if (p.getName().equals("biPositiveOrZero")){225 assertEquals(2, ((NumericConstraintBase)p).getPrecision());226 assertEquals(0, ((NumericConstraintBase)p).getScale());227 assertEquals("42", ((NumericConstraintBase)p).getMax().toString());228 assertEquals("0", ((NumericConstraintBase)p).getMin().toString());229 assertTrue(((NumericConstraintBase) p).getMinInclusive());230 assertTrue(((NumericConstraintBase) p).getMaxInclusive());231 } else if (p.getName().equals("biNegative")){232 assertEquals(2, ((NumericConstraintBase)p).getPrecision());233 assertEquals(0, ((NumericConstraintBase)p).getScale());234 assertEquals("0", ((NumericConstraintBase)p).getMax().toString());235 assertEquals("-42", ((NumericConstraintBase)p).getMin().toString());236 assertTrue(((NumericConstraintBase) p).getMinInclusive());237 assertFalse(((NumericConstraintBase) p).getMaxInclusive());238 } else if (p.getName().equals("biNegativeOrZero")){239 assertEquals(2, ((NumericConstraintBase)p).getPrecision());240 assertEquals(0, ((NumericConstraintBase)p).getScale());241 assertEquals("0", ((NumericConstraintBase)p).getMax().toString());242 assertEquals("-42", ((NumericConstraintBase)p).getMin().toString());243 assertTrue(((NumericConstraintBase) p).getMinInclusive());244 assertTrue(((NumericConstraintBase) p).getMaxInclusive());245 }246 }247 BigNumberObj bigNumberObj = new BigNumberObj(){{248 // bigdecimal249 setBdPositiveFloat(new BigDecimal("10.12"));250 setBdPositiveOrZeroFloat(new BigDecimal("0.00"));251 setBdNegativeFloat(new BigDecimal("-10.12"));252 setBdNegativeOrZeroFloat(new BigDecimal("-2.16"));253 // biginteger254 setBiPositive(BigInteger.TEN);255 setBiPositiveOrZero(BigInteger.ZERO);256 setBiNegative(BigInteger.valueOf(-10));257 setBiNegativeOrZero(BigInteger.valueOf(-2));258 }};259 p1.setValueBasedOnInstance(bigNumberObj);260 ParamDto dto = p1.getDto();261 assertNotNull(dto.stringValue);262 assertEquals(8, dto.innerContent.size());263 assertEquals("10.12", dto.innerContent.get(0).stringValue);264 assertEquals("-10.12", dto.innerContent.get(1).stringValue);265 assertEquals("0.00", dto.innerContent.get(2).stringValue);266 assertEquals("-2.16", dto.innerContent.get(3).stringValue);267 assertEquals("10", dto.innerContent.get(4).stringValue);268 assertEquals("0", dto.innerContent.get(5).stringValue);269 assertEquals("-10", dto.innerContent.get(6).stringValue);270 assertEquals("-2", dto.innerContent.get(7).stringValue);271 List<String> testScript = p1.newInstanceWithJava(0);272 assertEquals("com.thrift.example.artificial.BigNumberObj arg0 = null;",testScript.get(0));273 assertEquals("{",testScript.get(1));274 assertEquals(" arg0 = new com.thrift.example.artificial.BigNumberObj();",testScript.get(2));275 assertEquals(" java.math.BigDecimal arg0_bdPositiveFloat = null;",testScript.get(3));276 assertEquals(" {",testScript.get(4));277 assertEquals(" java.math.MathContext arg0_bdPositiveFloat_mc = new java.math.MathContext(4);",testScript.get(5));278 assertEquals(" arg0_bdPositiveFloat = new java.math.BigDecimal(\"10.12\", arg0_bdPositiveFloat_mc);",testScript.get(6));279 assertEquals(" arg0_bdPositiveFloat.setScale(2, java.math.RoundingMode.HALF_UP);",testScript.get(7));280 assertEquals(" }",testScript.get(8));281 assertEquals(" arg0.setBdPositiveFloat(arg0_bdPositiveFloat);",testScript.get(9));282 assertEquals(" java.math.BigDecimal arg0_bdNegativeFloat = null;",testScript.get(10));283 assertEquals(" {",testScript.get(11));284 assertEquals(" java.math.MathContext arg0_bdNegativeFloat_mc = new java.math.MathContext(4);",testScript.get(12));285 assertEquals(" arg0_bdNegativeFloat = new java.math.BigDecimal(\"-10.12\", arg0_bdNegativeFloat_mc);",testScript.get(13));286 assertEquals(" arg0_bdNegativeFloat.setScale(2, java.math.RoundingMode.HALF_UP);",testScript.get(14));287 assertEquals(" }",testScript.get(15));288 assertEquals(" arg0.setBdNegativeFloat(arg0_bdNegativeFloat);",testScript.get(16));289 assertEquals(" java.math.BigDecimal arg0_bdPositiveOrZeroFloat = null;",testScript.get(17));290 assertEquals(" {",testScript.get(18));291 assertEquals(" java.math.MathContext arg0_bdPositiveOrZeroFloat_mc = new java.math.MathContext(4);",testScript.get(19));292 assertEquals(" arg0_bdPositiveOrZeroFloat = new java.math.BigDecimal(\"0.00\", arg0_bdPositiveOrZeroFloat_mc);",testScript.get(20));293 assertEquals(" arg0_bdPositiveOrZeroFloat.setScale(2, java.math.RoundingMode.HALF_UP);",testScript.get(21));294 assertEquals(" }",testScript.get(22));295 assertEquals(" arg0.setBdPositiveOrZeroFloat(arg0_bdPositiveOrZeroFloat);",testScript.get(23));296 assertEquals(" java.math.BigDecimal arg0_bdNegativeOrZeroFloat = null;",testScript.get(24));297 assertEquals(" {",testScript.get(25));298 assertEquals(" java.math.MathContext arg0_bdNegativeOrZeroFloat_mc = new java.math.MathContext(4);",testScript.get(26));299 assertEquals(" arg0_bdNegativeOrZeroFloat = new java.math.BigDecimal(\"-2.16\", arg0_bdNegativeOrZeroFloat_mc);",testScript.get(27));300 assertEquals(" arg0_bdNegativeOrZeroFloat.setScale(2, java.math.RoundingMode.HALF_UP);",testScript.get(28));301 assertEquals(" }",testScript.get(29));302 assertEquals(" arg0.setBdNegativeOrZeroFloat(arg0_bdNegativeOrZeroFloat);",testScript.get(30));303 assertEquals(" java.math.BigInteger arg0_biPositive = null;",testScript.get(31));304 assertEquals(" {",testScript.get(32));305 assertEquals(" arg0_biPositive = new java.math.BigInteger(\"10\");",testScript.get(33));306 assertEquals(" }",testScript.get(34));307 assertEquals(" arg0.setBiPositive(arg0_biPositive);",testScript.get(35));308 assertEquals(" java.math.BigInteger arg0_biPositiveOrZero = null;",testScript.get(36));309 assertEquals(" {",testScript.get(37));310 assertEquals(" arg0_biPositiveOrZero = new java.math.BigInteger(\"0\");",testScript.get(38));311 assertEquals(" }",testScript.get(39));312 assertEquals(" arg0.setBiPositiveOrZero(arg0_biPositiveOrZero);",testScript.get(40));313 assertEquals(" java.math.BigInteger arg0_biNegative = null;",testScript.get(41));314 assertEquals(" {",testScript.get(42));315 assertEquals(" arg0_biNegative = new java.math.BigInteger(\"-10\");",testScript.get(43));316 assertEquals(" }",testScript.get(44));317 assertEquals(" arg0.setBiNegative(arg0_biNegative);",testScript.get(45));318 assertEquals(" java.math.BigInteger arg0_biNegativeOrZero = null;",testScript.get(46));319 assertEquals(" {",testScript.get(47));320 assertEquals(" arg0_biNegativeOrZero = new java.math.BigInteger(\"-2\");",testScript.get(48));321 assertEquals(" }",testScript.get(49));322 assertEquals(" arg0.setBiNegativeOrZero(arg0_biNegativeOrZero);",testScript.get(50));323 assertEquals("}",testScript.get(51));324 List<String> assertionScript = p1.newAssertionWithJava("arg0", 0);325 assertEquals("assertEquals(\"10.12\", arg0.getBdPositiveFloat().toString());", assertionScript.get(0));326 assertEquals("assertEquals(\"-10.12\", arg0.getBdNegativeFloat().toString());", assertionScript.get(1));327 assertEquals("assertEquals(\"0.00\", arg0.getBdPositiveOrZeroFloat().toString());", assertionScript.get(2));328 assertEquals("assertEquals(\"-2.16\", arg0.getBdNegativeOrZeroFloat().toString());", assertionScript.get(3));329 assertEquals("assertEquals(\"10\", arg0.getBiPositive().toString());", assertionScript.get(4));330 assertEquals("assertEquals(\"0\", arg0.getBiPositiveOrZero().toString());", assertionScript.get(5));331 assertEquals("assertEquals(\"-10\", arg0.getBiNegative().toString());", assertionScript.get(6));332 assertEquals("assertEquals(\"-2\", arg0.getBiNegativeOrZero().toString());", assertionScript.get(7));333 }334 @Test335 public void testEnumWithConstructor(){336 EndpointSchema endpoint = getOneEndpoint("handleEnumWithConstructor");337 assertNotNull(endpoint.getResponse());338 assertNotNull(endpoint.getRequestParams());339 assertEquals(1, endpoint.getRequestParams().size());340 NamedTypedValue p1 = endpoint.getRequestParams().get(0);341 assertTrue(p1 instanceof ObjectParam);342 ObjectEnum objectEnum = new ObjectEnum(){{343 enumWithConstructor = EnumWithConstructor.FIRST;344 }};345 p1.setValueBasedOnInstance(objectEnum);346 List<String> testScript = p1.newInstanceWithJava(0);347 assertEquals(5, testScript.size());348 assertEquals("com.thrift.example.artificial.ObjectEnum arg0 = null;", testScript.get(0));349 assertEquals("{", testScript.get(1));350 assertEquals(" arg0 = new com.thrift.example.artificial.ObjectEnum();", testScript.get(2));351 assertEquals(" arg0.enumWithConstructor = com.thrift.example.artificial.EnumWithConstructor.FIRST;", testScript.get(3));352 assertEquals("}", testScript.get(4));353 }354 @Test355 public void testNestedGeneric() throws ClassNotFoundException {356 EndpointSchema endpoint = getOneEndpoint("handleNestedGenericString");357 assertNotNull(endpoint.getResponse());358 assertNotNull(endpoint.getRequestParams());359 assertEquals(1, endpoint.getRequestParams().size());360 NamedTypedValue p1 = endpoint.getRequestParams().get(0);361 assertTrue(p1 instanceof ObjectParam);362 assertEquals(3, ((ObjectParam)p1).getType().getFields().size());363 assertNull(((ObjectParam)p1).getValue());364 Object p1Instance = p1.newInstance();365 assertNull(p1Instance);366 List<String> testScript = p1.newInstanceWithJava(0);367 ParamDto dto = p1.getDto();368 dto.innerContent = null;369 p1.setValueBasedOnDto(dto);370 List<String> testScriptWithDto = p1.newInstanceWithJava(0);371 assertEquals(testScript, testScriptWithDto);372 }373 @Test374 public void testLocalAuthSetup(){375 EndpointSchema endpoint = getOneEndpoint("authorizedEndpoint");376 assertTrue(endpoint.getRequestParams() == null || endpoint.getRequestParams().isEmpty());377 assertNotNull(endpoint.getResponse());378 RPCActionDto dto = endpoint.getDto();379 }380 @Test381 public void testEndpointsLoad() {382 assertEquals(expectedNumberOfEndpoints(), schema.getEndpoints().size());383 }384 @Test385 public void testAuthValueSetup() throws ClassNotFoundException {386 assertNotNull(schema.getAuthEndpoints());387 assertEquals(2, schema.getAuthEndpoints().size());388 for (Map.Entry<Integer, EndpointSchema> entry : schema.getAuthEndpoints().entrySet()){389 EndpointSchema endpointSchema = entry.getValue();390 assertEquals(1, endpointSchema.getRequestParams().size());391 NamedTypedValue p1 = endpointSchema.getRequestParams().get(0);392 assertTrue(p1 instanceof ObjectParam);393 Object p1Instance = p1.newInstance();394 assertTrue(p1Instance instanceof AuthLoginDto);395 if (entry.getKey().equals(0)){396 assertEquals("foo", ((AuthLoginDto) p1Instance).id);397 assertEquals("zXQV47zsrjfJRnTD", ((AuthLoginDto) p1Instance).passcode);398 }else if (entry.getKey().equals(1)){399 assertEquals("bar", ((AuthLoginDto) p1Instance).id);400 assertEquals("5jbNvXvaejDG5MhS", ((AuthLoginDto) p1Instance).passcode);401 }402 }403 }404 @Test405 public void testHandleCustomizedRequestA() {406 EndpointSchema endpoint = getOneEndpoint("handleCustomizedRequestA");407 assertNotNull(endpoint.getRelatedCustomizedCandidates());408 assertEquals(2, endpoint.getRelatedCustomizedCandidates().size());409 assertTrue(endpoint.getRelatedCustomizedCandidates().containsAll(Arrays.asList("0", "1")));410 NamedTypedValue p1 = endpoint.getRequestParams().get(0);411 assertTrue(p1 instanceof ObjectParam);412 assertTrue(p1.isNullable());413 assertEquals(3, ((ObjectParam) p1).getType().getFields().size());414 for (NamedTypedValue f : ((ObjectParam) p1).getType().getFields()) {415 if (f.getName().equals("value")) {416 assertTrue(f instanceof IntParam);417 assertNull(((IntParam) f).getMin());418 assertNull(((IntParam) f).getMax());419 } else if (f.getName().equals("id")) {420 assertTrue(f instanceof StringParam);421 assertNotNull(f.getCandidateReferences());422 assertNotNull(f.getCandidates());423 assertEquals(2, f.getCandidates().size());424 assertEquals(2, f.getCandidateReferences().size());425 IntStream.range(0, 1).forEach(i -> {426 assertTrue(f.getCandidates().get(i) instanceof StringParam);427 String value = ((StringParam) f.getCandidates().get(i)).getValue();428 if (f.getCandidateReferences().get(i).equals("0")) {429 assertEquals("foo", value);430 } else if (f.getCandidateReferences().get(i).equals("1")) {431 assertEquals("bar", value);432 }433 });434 } else if (f.getName().equals("passcode")) {435 assertTrue(f instanceof StringParam);436 assertNotNull(f.getCandidateReferences());437 assertNotNull(f.getCandidates());438 assertEquals(2, f.getCandidates().size());439 assertEquals(2, f.getCandidateReferences().size());440 IntStream.range(0, 1).forEach(i -> {441 assertTrue(f.getCandidates().get(i) instanceof StringParam);442 String value = ((StringParam) f.getCandidates().get(i)).getValue();443 if (f.getCandidateReferences().get(i).equals("0")) {444 assertEquals("foo_passcode", value);445 } else if (f.getCandidateReferences().get(i).equals("1")) {446 assertEquals("bar_passcode", value);447 }448 });449 } else450 fail("do not handle param " + f.getName());451 }452 }453 @Test454 public void testHandleCustomizedRequestB() {455 EndpointSchema endpoint = getOneEndpoint("handleCustomizedRequestB");456 assertNotNull(endpoint.getRelatedCustomizedCandidates());457 assertEquals(0, endpoint.getRelatedCustomizedCandidates().size());458 NamedTypedValue p1 = endpoint.getRequestParams().get(0);459 assertTrue(p1 instanceof ObjectParam);460 assertTrue(p1.isNullable());461 assertEquals(1, ((ObjectParam) p1).getType().getFields().size());462 NamedTypedValue f = ((ObjectParam) p1).getType().getFields().get(0);463 assertNull(f.getCandidateReferences());464 assertNotNull(f.getCandidates());465 assertEquals(3, f.getCandidates().size());466 List<Double> candidates = Arrays.asList(0.42, 42.42, 100.42);467 IntStream.range(0, 2).forEach(i -> {468 assertTrue(f.getCandidates().get(i) instanceof DoubleParam);469 Double value = ((DoubleParam) f.getCandidates().get(i)).getValue();470 assertTrue(candidates.contains(value));471 });472 }473 @Test474 public void testConstraintInputs() {475 EndpointSchema endpoint = getOneEndpoint("constraintInputs");476 assertNotNull(endpoint.getResponse());477 assertEquals(2, endpoint.getRequestParams().size());478 NamedTypedValue p1 = endpoint.getRequestParams().get(0);479 checkConstrainedRequest(p1);480 checkConstrainedRequest(p1.copyStructureWithProperties());481 NamedTypedValue p2 = endpoint.getRequestParams().get(1);482 assertTrue(p2 instanceof StringParam);483 assertFalse(p2.isNullable());484 ConstrainedRequest input = new ConstrainedRequest();485 p1.setValueBasedOnInstance(input);486 ParamDto dto = p1.getDto();487 dto.innerContent.get(1).stringValue = null;488 dto.innerContent.get(2).stringValue = null;489 p1.setValueBasedOnDto(dto);490 List<String> javaCode = p1.newInstanceWithJava(0);491 assertEquals(13, javaCode.size());492 assertEquals("com.thrift.example.artificial.ConstrainedRequest arg0 = null;", javaCode.get(0));493 assertEquals("{", javaCode.get(1));494 assertEquals(" arg0 = new com.thrift.example.artificial.ConstrainedRequest();", javaCode.get(2));495 assertEquals(" arg0.list = null;", javaCode.get(3));496 assertEquals(" arg0.notBlankString = null;", javaCode.get(4));497 assertEquals(" arg0.nullableString = null;", javaCode.get(5));498 assertEquals(" arg0.stringSize = null;", javaCode.get(6));499 assertEquals(" arg0.listSize = null;", javaCode.get(7));500 assertEquals(" arg0.kind = null;", javaCode.get(8));501 assertEquals(" arg0.date = null;", javaCode.get(9));502 assertEquals(" arg0.longWithDecimalMinMax = 0L;", javaCode.get(10));503 assertEquals(" arg0.longWithInclusiveFDecimalMainMax = null;", javaCode.get(11));504 assertEquals("}", javaCode.get(12));505 }506 private void checkConstrainedRequest(NamedTypedValue p){507 assertTrue(p instanceof ObjectParam);508 assertTrue(p.isNullable());509 assertEquals(11, ((ObjectParam) p).getType().getFields().size());510 for (NamedTypedValue f : ((ObjectParam) p).getType().getFields()) {511 if (f.getName().equals("list")) {512 assertTrue(f instanceof ListParam);513 assertFalse(f.isNullable());514 assertEquals(1, ((ListParam) f).getMinSize());515 } else if (f.getName().equals("listSize")) {516 assertTrue(f instanceof ListParam);517 assertEquals(1, ((ListParam) f).getMinSize());518 assertEquals(10, ((ListParam) f).getMaxSize());519 assertFalse(f.isNullable());520 } else if (f.getName().equals("intWithMinMax")) {521 assertTrue(f instanceof IntParam);522 assertEquals(0, ((IntParam) f).getMin().intValue());523 assertEquals(100, ((IntParam) f).getMax().intValue());524 assertFalse(f.isNullable());525 } else if (f.getName().equals("longWithMinMax")) {526 assertTrue(f instanceof LongParam);527 assertEquals(-100L, ((LongParam) f).getMin());528 assertEquals(1000L, ((LongParam) f).getMax());529 assertFalse(f.isNullable());530 } else if (f.getName().equals("notBlankString")) {531 assertTrue(f instanceof StringParam);532 assertFalse(f.isNullable());533 assertEquals(1, ((StringParam) f).getMinSize());534 } else if (f.getName().equals("nullableString")) {535 assertTrue(f instanceof StringParam);536 assertTrue(f.isNullable());537 } else if (f.getName().equals("stringSize")) {538 assertTrue(f instanceof StringParam);539 assertEquals(2, ((StringParam) f).getMinSize());540 assertEquals(10, ((StringParam) f).getMaxSize());541 assertTrue(f.isNullable());542 } else if(f.getName().equals("kind")){543 assertTrue(f instanceof EnumParam);544 assertFalse(f.isNullable());545 } else if(f.getName().equals("date")){546 assertTrue(f instanceof StringParam);547 assertTrue(f.isNullable());548 assertNotNull(((StringParam) f).getPattern());549 }else if(f.getName().equals("longWithDecimalMinMax")){550 assertTrue(f instanceof LongParam);551 assertEquals(1L, ((LongParam) f).getMin());552 assertEquals(10L, ((LongParam) f).getMax());553 assertFalse(f.isNullable());554 }else if(f.getName().equals("longWithInclusiveFDecimalMainMax")){555 assertTrue(f instanceof LongParam);556 assertEquals(1L, ((LongParam) f).getMin());557 assertFalse(((LongParam) f).getMinInclusive());558 assertEquals(10L, ((LongParam) f).getMax());559 assertFalse(((LongParam) f).getMaxInclusive());560 assertTrue(f.isNullable());561 }else562 fail("do not handle param " + f.getName());563 }564 }565 @Test566 public void testAccessFieldDtoCheck(){567 EndpointSchema endpoint = getOneEndpoint("accessFieldDtoCheck");568 assertNotNull(endpoint.getResponse());569 assertEquals(1, endpoint.getRequestParams().size());570 NamedTypedValue p1 = endpoint.getRequestParams().get(0);571 assertTrue(p1 instanceof ObjectParam);572 assertTrue(p1.getType() instanceof ObjectType);573 List<NamedTypedValue> fs = ((ObjectType) p1.getType()).getFields();574 assertEquals(13, fs.size());...

Full Screen

Full Screen

Source:NamedTypedValue.java Github

copy

Full Screen

...29 private V value;30 /**31 * represent whether this value is nullable32 */33 private boolean isNullable = true;34 /**35 * represent whether the value is mutable36 *37 * note that if the param is not mutable and the default value is null,38 * it represents that the value is a fixed NULL39 */40 private boolean isMutable = true;41 /**42 * default value for the parameter43 * it is nullable44 */45 private NamedTypedValue defaultValue;46 /**47 * a schema for collecting if the param is accessible48 */49 public final AccessibleSchema accessibleSchema;50 public boolean isHasDependentCandidates() {51 return hasDependentCandidates;52 }53 public void setHasDependentCandidates(boolean hasDependentCandidates) {54 this.hasDependentCandidates = hasDependentCandidates;55 }56 /**57 * represent whether there are specified dependent candidates58 */59 private boolean hasDependentCandidates = false;60 public List<NamedTypedValue> getCandidates() {61 return candidates;62 }63 public void setCandidates(List<NamedTypedValue> candidates) {64 this.candidates = candidates;65 }66 /**67 * represent candidates68 */69 private List<NamedTypedValue> candidates;70 public List<String> getCandidateReferences() {71 return candidateReferences;72 }73 public void setCandidateReferences(List<String> candidateReferences) {74 this.candidateReferences = candidateReferences;75 }76 /**77 * represent candidates78 */79 private List<String> candidateReferences;80 public NamedTypedValue(String name, T type, AccessibleSchema accessibleSchema) {81 this.name = name;82 this.type = type;83 this.accessibleSchema = accessibleSchema;84 }85 public String getName() {86 return name;87 }88 public T getType() {89 return type;90 }91 public V getValue() {92 return value;93 }94 public abstract Object newInstance() throws ClassNotFoundException;95 public void setValue(V value) {96 this.value = value;97 }98 public void setNullable(boolean nullable) {99 isNullable = nullable;100 }101 public boolean isNullable() {102 return isNullable;103 }104 /**105 * get its dto format in order to further handle it with evomastr core106 * @return its corresponding dto107 */108 public ParamDto getDto(){109 ParamDto dto = new ParamDto();110 dto.name = name;111 dto.type = type.getDto();112 dto.isNullable = isNullable;113 if (candidates!=null)114 dto.candidates = candidates.stream().map(NamedTypedValue::getDto).collect(Collectors.toList());115 if (candidateReferences!=null)116 dto.candidateReferences = new ArrayList<>(candidateReferences);117 dto.isMutable = isMutable;118 if (defaultValue != null)119 dto.defaultValue = defaultValue.getDto();120 return dto;121 }122 public NamedTypedValue<T, V> copyStructureWithProperties(){123 NamedTypedValue copy = copyStructure();124 copyProperties(copy);125 return copy;126 }127 public abstract NamedTypedValue<T, V> copyStructure();128 public void copyProperties(NamedTypedValue copy){129 copy.setNullable(isNullable);130 copy.setHasDependentCandidates(isHasDependentCandidates());131 copy.setMutable(isMutable());132 copy.setDefaultValue(getDefaultValue());133 if (getCandidates() != null && !getCandidates().isEmpty())134 copy.setCandidates(getCandidates().stream().map(c-> c.copyStructureWithProperties()).collect(Collectors.toList()));135 if (getCandidateReferences()!= null && !getCandidateReferences().isEmpty())136 copy.setCandidateReferences(new ArrayList<>(getCandidateReferences()));137 }138 /**139 * it is used to find a param schema based on info specified with dto format140 * @param dto specifies a param to check141 * @return whether [this] param schema info is consistent with the given dto142 */143 public boolean sameParam(ParamDto dto){...

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;2public class Main {3 public static void main(String[] args) {4 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", false, null);5 System.out.println("Is nullable: " + namedTypedValue.isNullable());6 }7}8import org.evomaster.client.java.controller.problem.rpc.schema.params.TypedValue;9public class Main {10 public static void main(String[] args) {11 TypedValue typedValue = new TypedValue("type", false, null);12 System.out.println("Is nullable: " + typedValue.isNullable());13 }14}15import org.evomaster.client.java.controller.problem.rest.param.Param;16public class Main {17 public static void main(String[] args) {18 Param param = new Param("name", "type", false, null);19 System.out.println("Is nullable: " + param.isNullable());20 }21}22import org.evomaster.client.java.controller.problem.rest.param.Param;23public class Main {24 public static void main(String[] args) {25 Param param = new Param("name", "type", true, null);26 System.out.println("Is nullable: " + param.isNullable());27 }28}29import org.evomaster.client.java.controller.problem.rest.param.Param;30public class Main {31 public static void main(String[] args) {32 Param param = new Param("name", "type", false, "defaultValue");33 System.out.println("Is nullable: " + param.isNullable());34 }35}36import

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;2public class 2 {3public static void main(String[] args) {4NamedTypedValue namedTypedValue = new NamedTypedValue();5namedTypedValue.setName("name");6namedTypedValue.setType("type");7namedTypedValue.setValue("value");8namedTypedValue.setNullable(true);9System.out.println(namedTypedValue.isNullable());10}11}

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1package org.evomaster.client.java.controller.problem.rpc.schema.params;2import org.evomaster.client.java.controller.problem.rpc.schema.RpcSchema;3import org.evomaster.client.java.controller.problem.rpc.schema.RpcType;4import org.evomaster.client.java.controller.problem.rest.param.Param;5import java.util.Objects;6public class NamedTypedValue implements RpcSchema {7 private String name;8 private RpcType type;9 private Boolean nullable;10 public NamedTypedValue() {11 }12 public NamedTypedValue(String name, RpcType type, Boolean nullable) {13 this.name = name;14 this.type = type;15 this.nullable = nullable;16 }17 public String getName() {18 return name;19 }20 public void setName(String name) {21 this.name = name;22 }23 public RpcType getType() {24 return type;25 }26 public void setType(RpcType type) {27 this.type = type;28 }29 public Boolean getNullable() {30 return nullable;31 }32 public void setNullable(Boolean nullable) {33 this.nullable = nullable;34 }35 public String toString() {36 return "NamedTypedValue{" +37 '}';38 }39 public boolean equals(Object o) {40 if (this == o) return true;41 if (o == null || getClass() != o.getClass()) return false;42 NamedTypedValue that = (NamedTypedValue) o;43 return Objects.equals(name, that.name) &&44 Objects.equals(type, that.type) &&45 Objects.equals(nullable, that.nullable);46 }47 public int hashCode() {48 return Objects.hash(name, type, nullable);49 }50}51package org.evomaster.client.java.controller.problem.rest.param;52import org.evomaster.client.java.controller.problem.rest.RestCallResult;53import org.evomaster.client.java.controller.problem.rest.RestIndividual;54import org.evomaster.client.java.controller.problem.rest.RestPath;55import org.evomaster.client.java.controller.problem.rest.param.Param;56import java.util.List;57import java.util.Objects;58public class Param implements RestIndividual {59 private String name;60 private String value;61 public Param() {62 }

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1import org.evomaster.client.java.controller.problem.rpc.schema.params.NamedTypedValue;2public class Example {3 public static void main(String[] args) {4 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", "value", true);5 Boolean isNullable = namedTypedValue.isNullable();6 System.out.println(isNullable);7 }8}

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static void main(String[] args) {3 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", false, true);4 System.out.println(namedTypedValue.isNullable());5 }6}7public class 3 {8 public static void main(String[] args) {9 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", false, false);10 System.out.println(namedTypedValue.isNullable());11 }12}13public class 4 {14 public static void main(String[] args) {15 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", true, false);16 System.out.println(namedTypedValue.isNullable());17 }18}19public class 5 {20 public static void main(String[] args) {21 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", true, true);22 System.out.println(namedTypedValue.isNullable());23 }24}25public class 6 {26 public static void main(String[] args) {27 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", true, false);28 System.out.println(namedTypedValue.isNullable());29 }30}31public class 7 {32 public static void main(String[] args) {33 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", false, true);34 System.out.println(namedTypedValue.isNullable());35 }36}

Full Screen

Full Screen

isNullable

Using AI Code Generation

copy

Full Screen

1public class 2 {2public static void main(String[] args) {3 NamedTypedValue namedTypedValue = new NamedTypedValue("name", "type", "value", true);4 System.out.println(namedTypedValue.isNullable());5}6}7public class 3 {8public static void main(String[] args) {9 TypedValue typedValue = new TypedValue("type", "value", true);10 System.out.println(typedValue.isNullable());11}12}13public class 4 {14public static void main(String[] args) {15 TypedValue typedValue = new TypedValue("type", "value", false);16 System.out.println(typedValue.isNullable());17}18}19public class 5 {20public static void main(String[] args) {21 TypedValue typedValue = new TypedValue("type", "value", null);22 System.out.println(typedValue.isNullable());23}24}25public class 6 {26public static void main(String[] args) {27 TypedValue typedValue = new TypedValue("type", "value");28 System.out.println(typedValue.isNullable());29}30}31public class 7 {32public static void main(String[] args) {33 TypedValue typedValue = new TypedValue("type", "value", true);34 System.out.println(typedValue.isNullable());35}36}37public class 8 {38public static void main(String[] args) {39 TypedValue typedValue = new TypedValue("type", "value", false);

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful