method2testcases
stringlengths 118
3.08k
|
---|
### Question:
Error extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Error(); private Error(Builder builder); String getCode(); void setCode(String code); String getType(); void setType(String type); String getMessage(); void setMessage(String message); String getDetail(); void setDetail(String detail); String getMoreInfo(); void setMoreInfo(String moreInfo); String getInfoLink(); void setInfoLink(String infoLink); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(error); String actualResult = error.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Capture extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Capture(); private Capture(Builder builder); Date getCreated(); void setCreated(Date created); BigDecimal getAmount(); void setAmount(BigDecimal amount); PaymentContext getContext(); void setContext(PaymentContext context); String getDescription(); void setDescription(String description); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(capture); String actualResult = capture.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Restaurant extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Restaurant(); private Restaurant(Builder builder); String getServerID(); void setServerID(String serverID); BigDecimal getFoodAmount(); void setFoodAmount(BigDecimal foodAmount); BigDecimal getBeverageAmount(); void setBeverageAmount(BigDecimal beverageAmount); BigDecimal getTaxAmount(); void setTaxAmount(BigDecimal taxAmount); BigDecimal getTipAmount(); void setTipAmount(BigDecimal tipAmount); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(restaurant); String actualResult = restaurant.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
DeviceInfo extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } DeviceInfo(); private DeviceInfo(Builder builder); String getId(); void setId(String id); String getType(); void setType(String type); String getLongitude(); void setLongitude(String longitude); String getLatitude(); void setLatitude(String latitude); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); String getMacAddress(); void setMacAddress(String macAddress); String getIpAddress(); void setIpAddress(String ipAddress); Boolean getEncrypted(); void setEncrypted(Boolean encrypted); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(deviceInfo); String actualResult = deviceInfo.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Lodging extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Lodging(); private Lodging(Builder builder); String getFolioID(); void setFolioID(String folioID); String getChargeType(); void setChargeType(String chargeType); Date getCheckInDate(); void setCheckInDate(Date checkInDate); Date getCheckOutDate(); void setCheckOutDate(Date checkOutDate); String getLengthOfStay(); void setLengthOfStay(String lengthOfStay); BigDecimal getRoomRate(); void setRoomRate(BigDecimal roomRate); String[] getExtraCharges(); void setExtraCharges(String[] extraCharges); String getSpecialProgram(); void setSpecialProgram(String specialProgram); BigDecimal getTotalAuthAmount(); void setTotalAuthAmount(BigDecimal totalAuthAmount); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(lodging); String actualResult = lodging.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
CvcVerification extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } CvcVerification(); private CvcVerification(Builder builder); String getResult(); void setResult(String result); Date getDate(); void setDate(Date date); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(cvcVerification); String actualResult = cvcVerification.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Address extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Address(); private Address(Builder builder); String getStreetAddress(); void setStreetAddress(String streetAddress); String getCity(); void setCity(String city); String getRegion(); void setRegion(String region); String getCountry(); void setCountry(String country); String getPostalCode(); void setPostalCode(String postalCode); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(address); String actualResult = address.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
CheckContext extends Entity { public DeviceInfo getDeviceInfo() { return deviceInfo; } CheckContext(); private CheckContext(Builder builder); DeviceInfo getDeviceInfo(); void setDeviceInfo(DeviceInfo deviceInfo); @Override String toString(); }### Answer:
@Test public void testAllGetters() { Assert.assertEquals(checkContext.getDeviceInfo(), deviceInfo); }
|
### Question:
CheckContext extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } CheckContext(); private CheckContext(Builder builder); DeviceInfo getDeviceInfo(); void setDeviceInfo(DeviceInfo deviceInfo); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(checkContext); String actualResult = checkContext.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Token extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Token(); private Token(Builder builder); String getValue(); void setValue(String value); Card getCard(); void setCard(Card card); BankAccount getBankAccount(); void setBankAccount(BankAccount bankAccount); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(token); String actualResult = token.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
ECheck extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } ECheck(); private ECheck(Builder builder); String getId(); void setId(String id); Date getCreated(); void setCreated(Date created); BigDecimal getAmount(); void setAmount(BigDecimal amount); String getToken(); void setToken(String token); String getAuthCode(); void setAuthCode(String authCode); String getDescription(); void setDescription(String description); ECheckStatus getStatus(); void setStatus(ECheckStatus status); BankAccount getBankAccount(); void setBankAccount(BankAccount bankAccount); String getBankAccountOnFile(); void setBankAccountOnFile(String bankAccountOnFile); CheckContext getContext(); void setContext(CheckContext context); PaymentModeType getPaymentMode(); void setPaymentMode(PaymentModeType paymentMode); String getCheckNumber(); void setCheckNumber(String checkNumber); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(echeck); String actualResult = echeck.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
Charge extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } Charge(); private Charge(Builder builder); String getId(); void setId(String id); Date getCreated(); void setCreated(Date created); ChargeStatus getStatus(); void setStatus(ChargeStatus status); BigDecimal getAmount(); void setAmount(BigDecimal amount); String getCurrency(); void setCurrency(String currency); String getToken(); void setToken(String token); Card getCard(); void setCard(Card card); PaymentContext getContext(); void setContext(PaymentContext context); Boolean getCapture(); void setCapture(Boolean capture); String getAuthCode(); void setAuthCode(String authCode); Capture getCaptureDetail(); void setCaptureDetail(Capture captureDetail); Refund[] getRefundDetail(); void setRefundDetail(Refund[] refundDetail); String getDescription(); void setDescription(String description); String getAvsStreet(); void setAvsStreet(String avsStreet); String getAvsZip(); void setAvsZip(String avsZip); String getCardSecurityCodeMatch(); void setCardSecurityCodeMatch(String cardSecurityCodeMatch); String getAppType(); void setAppType(String appType); String getCardOnFile(); void setCardOnFile(String cardOnFile); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(charge); String actualResult = charge.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
BankAccount extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } BankAccount(); private BankAccount(Builder builder); String getId(); void setId(String id); Date getCreated(); void setCreated(Date created); Date getUpdated(); void setUpdated(Date updated); String getName(); void setName(String name); String getRoutingNumber(); void setRoutingNumber(String routingNumber); String getAccountNumber(); void setAccountNumber(String accountNumber); AccountType getAccountType(); void setAccountType(AccountType accountType); String getPhone(); void setPhone(String phone); String getCountry(); void setCountry(String country); BankAccountInputTypeEnum getInputType(); void setInputType(BankAccountInputTypeEnum inputType); String getBankCode(); void setBankCode(String bankCode); Boolean getDefaultValue(); void setDefaultValue(Boolean defaultValue); String getEntityId(); void setEntityId(String entityId); String getEntityType(); void setEntityType(String entityType); String getEntityVersion(); void setEntityVersion(String entityVersion); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(bankAccount); String actualResult = bankAccount.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
QueryResponse extends Entity { @Override public String toString() { return ReflectionToStringBuilder.toString(this); } QueryResponse(); private QueryResponse(Builder builder); List<BankAccount> getBankAccounts(); void setBankAccounts(List<BankAccount> bankAccounts); List<Card> getCards(); void setCards(List<Card> cards); @Override String toString(); }### Answer:
@Test public void testToString() { String expectedResult = ReflectionToStringBuilder.toString(queryResponse); String actualResult = queryResponse.toString(); Assert.assertTrue(actualResult.contains(expectedResult)); }
|
### Question:
JsonUtil { public static String serialize(Object obj) throws SerializationException { try { if (obj != null) { return mapper.writeValueAsString(obj); } else { return null; } } catch (Exception e) { logger.error("SerializationException {}", e.getMessage()); throw new SerializationException(e.getMessage()); } } static String serialize(Object obj); static Object deserialize(String json, TypeReference<?> typeReference); static ObjectMapper mapper; static final String TIMEZONE_UTC; static final String DATETIMEFORMAT; }### Answer:
@Test public void testSerialize() throws SerializationException { Card card = new Card.Builder().number("12345").build(); String cardStr = JsonUtil.serialize(card); Assert.assertNotNull(cardStr); String result = "{" + System.lineSeparator() + " \"number\" : \"12345\"" + System.lineSeparator() + "}"; Assert.assertEquals(cardStr, result); }
@Test public void testNullSerialize() throws SerializationException { String cardStr = JsonUtil.serialize(null); Assert.assertNull(cardStr); }
@Test(expectedExceptions = SerializationException.class) public void testErrorSerialize() throws SerializationException { ClassWithPrivateFields classWithPrivateFields = new ClassWithPrivateFields(1, "John"); JsonUtil.serialize(classWithPrivateFields); }
|
### Question:
JsonUtil { public static Object deserialize(String json, TypeReference<?> typeReference) throws SerializationException { try { logger.debug("Json string to deserialize {} ", json); return mapper.readValue(json, typeReference); } catch (IOException e) { logger.error("SerializationException {}", e.getMessage()); SerializationException serializationException = new SerializationException(e); throw serializationException; } } static String serialize(Object obj); static Object deserialize(String json, TypeReference<?> typeReference); static ObjectMapper mapper; static final String TIMEZONE_UTC; static final String DATETIMEFORMAT; }### Answer:
@Test public void testDeserialize() throws SerializationException { String cardStr = "{\"number\":\"12345\"}"; Card card = (Card) JsonUtil.deserialize(cardStr, new TypeReference<Card>() {} ); Assert.assertEquals(card.getNumber(), "12345"); }
@Test(expectedExceptions = SerializationException.class) public void testErrorDeserialize() throws SerializationException { String cardStr = "{\"number\":\"12345\"\"}"; JsonUtil.deserialize(cardStr, new TypeReference<Card>() {} ); }
@SuppressWarnings("unchecked") @Test public void testDeserializeList() throws SerializationException { String cardList = "[{\"number\":\"12345\"}]"; List<Card> cards = (List<Card>) JsonUtil.deserialize(cardList, new TypeReference<List<Card>>() {} ); Assert.assertEquals(cards.size(), 1); Assert.assertEquals(cards.get(0).getNumber(), "12345"); }
|
### Question:
TokenService extends ServiceBase { public RequestContext getRequestContext() { return requestContext; } TokenService(RequestContext requestContext); protected TokenService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Token createToken(Token token); }### Answer:
@Test public void testTokenServiceCreation() { TokenService tokenService = new TokenService(); Assert.assertNull(tokenService.getRequestContext()); }
|
### Question:
CardService extends ServiceBase { public Card create(Card card, String customerId) throws BaseException { logger.debug("Enter CardService::create"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<Card> typeReference = new TypeReference<Card>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(card) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Card cardResponse = (Card) response.getResponseObject(); prepareResponse(request, response, cardResponse); return cardResponse; } CardService(RequestContext requestContext); protected CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count); }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testcreateCustomerBlank() throws BaseException { CardService cardService = new CardService(); cardService.create(new Card(), ""); }
|
### Question:
CardService extends ServiceBase { public Card createFromToken(Token token, String customerId) throws BaseException { logger.debug("Enter CardService::createFromToken"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/createFromToken" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()); logger.info("apiUrl - " + apiUrl); TypeReference<Card> typeReference = new TypeReference<Card>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(token) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); Card cardResponse = (Card) response.getResponseObject(); prepareResponse(request, response, cardResponse); return cardResponse; } CardService(RequestContext requestContext); protected CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count); }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testcreateFromTokenCustomerBlank() throws BaseException { CardService cardService = new CardService(); cardService.createFromToken(new Token(), ""); }
|
### Question:
CardService extends ServiceBase { public Card delete(String customerId, String cardId) throws BaseException { logger.debug("Enter CardService::delete"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(cardId)) { logger.error("IllegalArgumentException {}", cardId); throw new IllegalArgumentException("cardId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/{card_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "card_id" + "\\}", cardId); logger.info("apiUrl - " + apiUrl); Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build(); Response response = sendRequest(request); Card cardResponse = new Card(); prepareResponse(request, response, cardResponse); return cardResponse; } CardService(RequestContext requestContext); protected CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count); }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testdeleteCustomerBlank() throws BaseException { CardService cardService = new CardService(); cardService.delete("", ""); }
|
### Question:
CardService extends ServiceBase { public Card getCard(String customerId, String cardId) throws BaseException { logger.debug("Enter CardService::getCard"); if (StringUtils.isBlank(customerId)) { logger.error("IllegalArgumentException {}", customerId); throw new IllegalArgumentException("customerId cannot be empty or null"); } if (StringUtils.isBlank(cardId)) { logger.error("IllegalArgumentException {}", cardId); throw new IllegalArgumentException("cardId cannot be empty or null"); } String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/{card_id}" .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString()) .replaceAll("\\{" + "card_id" + "\\}", cardId); logger.info("apiUrl - " + apiUrl); TypeReference<Card> typeReference = new TypeReference<Card>() { }; Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference) .context(requestContext).build(); Response response = sendRequest(request); Card cardResponse = (Card) response.getResponseObject(); prepareResponse(request, response, cardResponse); return cardResponse; } CardService(RequestContext requestContext); protected CardService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Card create(Card card, String customerId); Card createFromToken(Token token, String customerId); Card delete(String customerId, String cardId); Card getCard(String customerId, String cardId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllCards(String customerId, int count); }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testgetCardCustomerBlank() throws BaseException { CardService cardService = new CardService(); cardService.getCard("", "12345"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testgetCardCardIdBlank() throws BaseException { CardService cardService = new CardService(); cardService.getCard("customerid", ""); }
|
### Question:
ECheckService extends ServiceBase { public RequestContext getRequestContext() { return requestContext; } ECheckService(RequestContext requestContext); protected ECheckService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); ECheck create(ECheck eCheck); ECheck retrieve(String eCheckId); Refund refund(String eCheckId, Refund refund); Refund getRefund(String eCheckId, String refundId); }### Answer:
@Test public void testECheckServiceCreation() { ECheckService eCheckService = new ECheckService(); Assert.assertNull(eCheckService.getRequestContext()); }
|
### Question:
ECheckService extends ServiceBase { public ECheck create(ECheck eCheck) throws BaseException { logger.debug("Enter ECheckService::create"); String apiUrl = requestContext.getBaseUrl() + "echecks".replaceAll("\\{format\\}", "json"); logger.info("apiUrl - " + apiUrl); TypeReference<ECheck> typeReference = new TypeReference<ECheck>() { }; Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(eCheck) .typeReference(typeReference).context(requestContext).build(); Response response = sendRequest(request); ECheck eCheckResponse = (ECheck) response.getResponseObject(); prepareResponse(request, response, eCheckResponse); return eCheckResponse; } ECheckService(RequestContext requestContext); protected ECheckService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); ECheck create(ECheck eCheck); ECheck retrieve(String eCheckId); Refund refund(String eCheckId, Refund refund); Refund getRefund(String eCheckId, String refundId); }### Answer:
@Test public void testCreateECheck() throws BaseException { ECheck expectedECheck = new ECheck.Builder().id("ijids").amount(new BigDecimal("50000")).build(); final String eCheckString = JsonUtil.serialize(expectedECheck); final Response mockedResponse = new Response(200, eCheckString, "fjkdlsfd"); mockedResponse.setResponseObject(expectedECheck); new Expectations() {{ serviceBase.sendRequest((Request) any); result = mockedResponse; }}; RequestContext requestContext = new RequestContext(); requestContext.setBaseUrl("fakeBaseUrl"); ECheckService eCheckService = new ECheckService(requestContext); try { ECheck eCheck = new ECheck(); ECheck eCheckGenerated = eCheckService.create(eCheck); Assert.assertEquals(expectedECheck, eCheckGenerated); } catch (BaseException e) { Assert.fail("Unexpected BaseException thrown " + e.getMessage()); } }
|
### Question:
BankAccountService extends ServiceBase { public RequestContext getRequestContext() { return requestContext; } BankAccountService(RequestContext requestContext); protected BankAccountService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); BankAccount create(BankAccount bankAccount, String customerId); BankAccount createFromToken(Token token, String customerId); BankAccount delete(String customerId, String bankaccountId); BankAccount getBankAccount(String customerId, String bankaccountId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId); @SuppressWarnings("unchecked") QueryResponse getAllBankAccounts(String customerId, int count); }### Answer:
@Test public void testBankAccountServiceCreation() { BankAccountService bankService = new BankAccountService(); Assert.assertNull(bankService.getRequestContext()); }
|
### Question:
ChargeService extends ServiceBase { public RequestContext getRequestContext() { return requestContext; } ChargeService(RequestContext requestContext); protected ChargeService(); RequestContext getRequestContext(); void setRequestContext(RequestContext requestContext); Charge create(Charge charge); Charge retrieve(String chargeId); Charge capture(String chargeId, Capture capture); Refund refund(String chargeId, Refund refund); Refund getRefund(String chargeId, String refundId); Refund voidTransaction(String chargeRequestId); }### Answer:
@Test public void testChargeServiceCreation() { ChargeService chargeService = new ChargeService(); Assert.assertNull(chargeService.getRequestContext()); }
|
### Question:
ServiceBase { public void prepareResponse(Request request, Response response, Entity entity) { entity.setIntuit_tid(response.getIntuit_tid()); entity.setRequestId(request.getContext().getRequestId()); } Response sendRequest(Request serviceRequest); void prepareResponse(Request request, Response response, Entity entity); }### Answer:
@Test public void testPrepareResponse_success() { String expectedRequestId = "146-request-id"; String expectedTid = "112-tid"; RequestContext requestContext = new RequestContext(); requestContext.setRequestId(expectedRequestId); Request request = new Request.RequestBuilder(MethodType.GET, "url") .context(requestContext) .build(); Response response = new Response(200, "{}", expectedTid); Entity entity = new Entity() {}; serviceBase.prepareResponse(request, response, entity); Assert.assertEquals(entity.getIntuit_tid(), expectedTid); Assert.assertEquals(entity.getRequestId(), expectedRequestId); }
|
### Question:
Response { public InputStream getStream() { return stream; } Response(final InputStream stream, final int statusCode, final String intuit_tid); String getContent(); int getStatusCode(); InputStream getStream(); String getIntuit_tid(); }### Answer:
@Test public void testGetStream() throws UnsupportedEncodingException, ConnectionException { String content = "frobozz"; InputStream istream = new ByteArrayInputStream(content.getBytes("UTF-8")); String intuit_tid = "abcd-123-xyz"; Response response = new Response(istream, 200, intuit_tid); assertEquals(istream, response.getStream()); assertEquals(content, response.getContent()); assertEquals(intuit_tid, response.getIntuit_tid()); }
|
### Question:
Request { public URL constructURL() throws InvalidRequestException { String stringUri = url; try { URI uri = new URI(stringUri); return uri.toURL(); } catch (final URISyntaxException e) { throw new InvalidRequestException("Bad URI: " + stringUri, e); } catch (final MalformedURLException e) { throw new InvalidRequestException("Bad URL: " + stringUri, e); } } private Request(RequestBuilder builder); MethodType getMethod(); String getUrl(); boolean isRequiresAuthentication(); String getAuthString(); List<NameValuePair> getPostParams(); String getPostJson(); URL constructURL(); }### Answer:
@Test public void testConstructURL() throws PlatformException, MalformedURLException { Request request = new Request.RequestBuilder(MethodType.GET, oauth2Config.getIntuitBearerTokenEndpoint()).build(); URL url = request.constructURL(); URL expected = new URL(oauth2Config.getIntuitBearerTokenEndpoint()); assertEquals(expected, url); }
|
### Question:
PlatformResponse { public String getErrorCode() { return errorCode; } String getErrorCode(); void setErrorCode(String errorCode); String getErrorMessage(); void setErrorMessage(String errorMessage); String getStatus(); void setStatus(String status); String getIntuit_tid(); void setIntuit_tid(String intuit_tid); }### Answer:
@Test public void testGetErrorCode() { PlatformResponse resp = new PlatformResponse(); resp.setErrorCode("200"); assertEquals(resp.getErrorCode(),"200"); }
|
### Question:
PlatformResponse { public String getStatus() { return status; } String getErrorCode(); void setErrorCode(String errorCode); String getErrorMessage(); void setErrorMessage(String errorMessage); String getStatus(); void setStatus(String status); String getIntuit_tid(); void setIntuit_tid(String intuit_tid); }### Answer:
@Test public void testGetStatus() { PlatformResponse resp = new PlatformResponse(); resp.setStatus("Status"); assertEquals(resp.getStatus(),"Status"); }
|
### Question:
OAuth2Config { public String generateCSRFToken() { logger.debug("Enter OAuth2config::generateCSRFToken"); return UUID.randomUUID().toString(); } private OAuth2Config(OAuth2ConfigBuilder builder); String getIntuitIdTokenIssuer(); String getIntuitAuthorizationEndpoint(); String getIntuitBearerTokenEndpoint(); String getIntuitRevokeTokenEndpoint(); String getIntuitJwksURI(); String getUserProfileEndpoint(); String getClientId(); String getClientSecret(); ProxyConfig getProxyConfig(); void setIntuitAuthorizationEndpoint(String intuitAuthorizationEndpoint); void setIntuitBearerTokenEndpoint(String intuitBearerTokenEndpoint); void setIntuitRevokeTokenEndpoint(String intuitRevokeTokenEndpoint); void setUserProfileEndpoint(String userProfileEndpoint); void setIntuitIdTokenIssuer(String intuitIdTokenIssuer); void setIntuitJwksURI(String intuitJwksURI); String getScopeValue(Scope scope); String generateCSRFToken(); String prepareUrl(List<Scope> scopes, String redirectUri, String csrfToken); String prepareUrl(List<Scope> scopes, String redirectUri); String prepareUrlWithCustomScopes(List<String> scopes, String redirectUri); String prepareUrlWithCustomScopes(List<String> scopes, String redirectUri, String csrfToken); }### Answer:
@Test public void testGenerateCSRFToken() { String csrf = oauth2Config.generateCSRFToken(); assertNotNull(csrf); }
|
### Question:
StringUtils { public static boolean hasBytes(final byte[] data) { if (data != null && data.length > 0) { return true; } return false; } private StringUtils(); static StringUtils getInstance(); static boolean hasText(final String text); static boolean hasBytes(final byte[] data); }### Answer:
@Test public void testHasBytes_true() { byte[] data = "data".getBytes(); boolean status = StringUtils.hasBytes(data); Assert.assertTrue(status); }
@Test public void testHasBytes_false() { byte[] data = "".getBytes(); boolean status = StringUtils.hasBytes(data); Assert.assertFalse(status); }
@Test public void testHasBytes_null() { boolean status = StringUtils.hasBytes(null); Assert.assertFalse(status); }
|
### Question:
JSONSerializer implements IEntitySerializer { @SuppressWarnings("unchecked") public <T> String serialize(T object) throws SerializationException { if (object == null) { return null; } ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary); mapper.setAnnotationIntrospector(pair); mapper.setSerializationInclusion(Include.NON_NULL); registerModulesForEnum(mapper); SimpleModule testModule = new SimpleModule("BatchItemRequest", new Version(1, 0, 0, null)); testModule.addSerializer(BatchItemRequest.class, new BatchItemRequestSerializer()); mapper.registerModule(testModule); testModule = new SimpleModule("RecurringTransaction", new Version(1, 0, 0, null)); testModule.addSerializer(RecurringTransaction.class, new RecurringTransactionSerializer()); mapper.registerModule(testModule); String json = null; try { if(object instanceof TaxService) { json = mapper.writeValueAsString(((TaxService) object)); } else { json = mapper.writeValueAsString(((JAXBElement<T>) object).getValue()); } } catch (Exception e) { LOG.error("Exception while json serialize", e); throw new SerializationException(e); } return json; } @SuppressWarnings("unchecked") String serialize(T object); Response deserialize(String json, Class<?> cl); @Override Response deserializeEntitlements(String decompressedData, Class<EntitlementsResponse> cl); }### Answer:
@Test public void testSerialize() throws FMSException { Customer s = new Customer(); s.setContactName("Aditi"); String x = jsonObj.serialize(getSerializableRequestObject(s)); Assert.assertEquals(x, "{\"ContactName\":\"Aditi\"}"); }
@Test public void testSerialize_null() throws Exception { String str = jsonObj.serialize(null); Assert.assertNull(str); }
|
### Question:
XMLSerializer implements IEntitySerializer { public <T> String serialize(T object) throws SerializationException { if (object == null) { return null; } StringWriter writer = new StringWriter(); try { Marshaller marshaller = MessageUtils.createMarshaller(); marshaller.marshal(object, writer); } catch (JAXBException e) { LOG.error("unable to marshall in XML Serializer", e); throw new SerializationException(e); } String documentToPost = writer.toString(); LOG.debug("XML serialized data : " + documentToPost); return documentToPost; } String serialize(T object); @SuppressWarnings("unchecked") Response deserialize(String str, Class<?> cl); @Override Response deserializeEntitlements(String decompressedData, Class<EntitlementsResponse> cl); }### Answer:
@Test public void testSerialize() throws Exception { Customer c = new Customer(); c.setCompanyName("Aditi"); String str = xmlobj.serialize(getIntuitObject(c)); Assert.assertEquals(str, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<Customer xmlns=\"http: }
@Test public void testSerialize_null() throws Exception { String str = xmlobj.serialize(null); Assert.assertNull(str); }
@Test public void testSerialize_BatchRequest() throws SerializationException { IntuitBatchRequest batchRequest = new IntuitBatchRequest(); List<BatchItemRequest> list = new ArrayList<BatchItemRequest>(); Customer customerIn = new Customer(); customerIn.setId("NG:2285964"); customerIn.setSparse(true); customerIn.setDisplayName("updated"); BatchItemRequest batchItemRequest = new BatchItemRequest(); batchItemRequest.setBId("123"); batchItemRequest.setOperation(OperationEnum.UPDATE); batchItemRequest.setIntuitObject(getIntuitObject(customerIn)); list.add(batchItemRequest); batchRequest.setBatchItemRequest(list); String data = new XMLSerializer().serialize(getSerializableRequestObject(batchRequest)); Assert.assertNotNull(data); }
|
### Question:
StringUtils { private StringUtils() { } private StringUtils(); static StringUtils getInstance(); static boolean hasText(final String text); static boolean hasBytes(final byte[] data); }### Answer:
@Test public void testStringUtils() { StringUtils stringUtils = StringUtils.getInstance(); Assert.assertNotNull(stringUtils); }
|
### Question:
SerializerFactory { public static IEntitySerializer getSerializer(final String serializeFormat) throws SerializationException { IEntitySerializer serializer = null; if (isValidSerializeFormat(serializeFormat)) { if (serializeFormat.equalsIgnoreCase(XML_SERIALIZE_FORMAT)) { serializer = new XMLSerializer(); } else if (serializeFormat.equalsIgnoreCase(JSON_SERIALIZE_FORMAT)) { serializer = new JSONSerializer(); } } return serializer; } private SerializerFactory(); static SerializerFactory getInstance(); static IEntitySerializer getSerializer(final String serializeFormat); static boolean isValidSerializeFormat(final String serializeFormat); static final String XML_SERIALIZE_FORMAT; static final String JSON_SERIALIZE_FORMAT; }### Answer:
@Test public void testGetSerializer_xml() throws SerializationException { IEntitySerializer serializer = SerializerFactory.getSerializer("xml"); Assert.assertTrue(serializer instanceof XMLSerializer, "Object serializer is not instance of XMLSerializer"); }
@Test public void testGetSerializer_json() throws SerializationException { IEntitySerializer serializer = SerializerFactory.getSerializer("json"); Assert.assertTrue(serializer instanceof JSONSerializer, "Object serializer is not instance of JSONSerializer"); }
@Test public void testGetSerializer_others() throws SerializationException { boolean isException = false; try { SerializerFactory.getSerializer("others"); } catch (SerializationException e) { isException = true; } Assert.assertTrue(isException); }
@Test public void testGetSerializer_null() throws SerializationException { boolean isException = false; try { SerializerFactory.getSerializer(null); } catch (SerializationException e) { isException = true; } Assert.assertTrue(isException); }
|
### Question:
SerializerFactory { public static boolean isValidSerializeFormat(final String serializeFormat) throws SerializationException { if (!StringUtils.hasText(serializeFormat)) { throw new SerializationException("serialization format is either null or empty!"); } else if (serializeFormat.equalsIgnoreCase(XML_SERIALIZE_FORMAT) || serializeFormat.equalsIgnoreCase(JSON_SERIALIZE_FORMAT)) { return true; } else { throw new SerializationException("Serializer not supported for the given serialization format : " + serializeFormat); } } private SerializerFactory(); static SerializerFactory getInstance(); static IEntitySerializer getSerializer(final String serializeFormat); static boolean isValidSerializeFormat(final String serializeFormat); static final String XML_SERIALIZE_FORMAT; static final String JSON_SERIALIZE_FORMAT; }### Answer:
@Test public void testIsValidSerializationFormat_xml() throws SerializationException { boolean isValid = SerializerFactory.isValidSerializeFormat("xml"); Assert.assertTrue(isValid); }
@Test public void testIsValidSerializationFormat_json() throws SerializationException { boolean isValid = SerializerFactory.isValidSerializeFormat("json"); Assert.assertTrue(isValid); }
@Test public void testIsValidSerializationFormat_others() throws SerializationException { boolean isValid = false; try { isValid = SerializerFactory.isValidSerializeFormat("others"); } catch (SerializationException e) { isValid = false; } Assert.assertFalse(isValid); }
@Test public void testIsValidSerializationFormat_null() throws SerializationException { boolean isValid = false; try { isValid = SerializerFactory.isValidSerializeFormat(null); } catch (SerializationException e) { isValid = false; } Assert.assertFalse(isValid); }
|
### Question:
DateUtils { public static Date getCurrentDateTime() throws ParseException { Calendar currentDate = Calendar.getInstance(); SimpleDateFormat formatter = new SimpleDateFormat(DATE_yyyyMMddTHHmmssSSSZ); String dateNow = formatter.format(currentDate.getTime()); return getDateFromString(dateNow); } private DateUtils(); static DateUtils getInstance(); static Date getDateFromString(String date); static Date getCurrentDateTime(); static Date getDateWithNextDays(int noOfDays); static Date getDateWithPrevDays(int noOfDays); static String getStringFromDateTime(Date date); static final String DATE_yyyyMMddTHHmmssSSSZ; static final String DATE_yyyMMddTHHmmssZ; static final String DATE_yyyyMMddTHHmmssSSSZone; static final String DATE_yyyMMddTHHmmssZone; }### Answer:
@Test public void testGetCurrentDateTime() throws Exception { Date c = DateUtils.getCurrentDateTime(); Assert.assertNotNull(c); }
|
### Question:
SerializerFactory { private SerializerFactory() { } private SerializerFactory(); static SerializerFactory getInstance(); static IEntitySerializer getSerializer(final String serializeFormat); static boolean isValidSerializeFormat(final String serializeFormat); static final String XML_SERIALIZE_FORMAT; static final String JSON_SERIALIZE_FORMAT; }### Answer:
@Test public void testSerializerFactory() { SerializerFactory factory = SerializerFactory.getInstance(); Assert.assertNotNull(factory); }
|
### Question:
OAuth2Authorizer implements IAuthorizer { @Override public void authorize(HttpRequestBase httpRequest) throws FMSException { httpRequest.setHeader("Authorization", "Bearer " + accessToken); } OAuth2Authorizer(String accessToken); @Override void authorize(HttpRequestBase httpRequest); @Override void authorize(HttpURLConnection httpUrlConnection); String getAccessToken(); void setAccessToken(String accessToken); }### Answer:
@Test public void oAuthAuthorizerWithAccessTokenSecret() { String accessToken = "TestAccessToken"; Header[] header = null; HttpRequestBase requestBase = new HttpGet(); try { requestBase.setURI(new URI(URL_STRING)); OAuth2Authorizer oauthAuthorizer = new OAuth2Authorizer(accessToken); oauthAuthorizer.authorize(requestBase); header = requestBase.getAllHeaders(); Assert.assertEquals("Bearer "+accessToken,extractHeaderParams(header, requestBase)); } catch (Exception e) { log.debug(e.getMessage()); } }
@Test public void oAuthAuthorizerWithAccessTokenSecretHttpUrlConnection() { String accessToken = "TestAccessToken"; Config.setProperty(Config.HTTP_TRANSPORT, HTTPURLConnectionInterceptor.HTTP_URL_CONNECTION); try { URL url = new URL(URL_STRING); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); OAuth2Authorizer oauthAuthorizer = new OAuth2Authorizer(accessToken); oauthAuthorizer.authorize(conn); } catch (Exception e) { log.debug(e.getMessage()); Assert.fail("Exception should not happen"); } }
|
### Question:
RetryHelper { public static void argumentNotNegativeValue(long argumentValue, String argumentName) throws ConfigurationException { if (argumentValue < 0) { throw new ConfigurationException("The value for argument name [" + argumentName + "] is negative [" + argumentValue + "]. Please check the configuration."); } } private RetryHelper(); static void argumentNotNegativeValue(long argumentValue, String argumentName); }### Answer:
@Test public void testArgumentNegativeValue() { long argumentValue = -5; String argumentName = "argumentValue"; boolean isValid = true; try { RetryHelper.argumentNotNegativeValue(argumentValue, argumentName); } catch (ConfigurationException nve) { isValid = false; } Assert.assertFalse(isValid); }
@Test public void testArgumentNotNegativeValue() { long argumentValue = 5; String argumentName = "argumentValue"; boolean isValid = true; try { RetryHelper.argumentNotNegativeValue(argumentValue, argumentName); } catch (ConfigurationException nve) { isValid = false; } Assert.assertTrue(isValid); }
|
### Question:
DateUtils { private DateUtils() { } private DateUtils(); static DateUtils getInstance(); static Date getDateFromString(String date); static Date getCurrentDateTime(); static Date getDateWithNextDays(int noOfDays); static Date getDateWithPrevDays(int noOfDays); static String getStringFromDateTime(Date date); static final String DATE_yyyyMMddTHHmmssSSSZ; static final String DATE_yyyMMddTHHmmssZ; static final String DATE_yyyyMMddTHHmmssSSSZone; static final String DATE_yyyMMddTHHmmssZone; }### Answer:
@Test public void testDateUtils() { DateUtils dateUtils = DateUtils.getInstance(); Assert.assertNotNull(dateUtils); }
|
### Question:
CallbackHandlerInterceptor implements Interceptor { private QueryResult getQueryResult(QueryResponse queryResponse) { QueryResult queryResult = null; if (queryResponse != null) { queryResult = new QueryResult(); queryResult.setEntities(getEntities(queryResponse)); queryResult.setFault(queryResponse.getFault()); queryResult.setMaxResults(queryResponse.getMaxResults()); queryResult.setStartPosition(queryResponse.getStartPosition()); queryResult.setTotalCount(queryResponse.getTotalCount()); } return queryResult; } @Override void execute(IntuitMessage intuitMessage); }### Answer:
@Test public void queryIsOk() throws FMSException { final QueryResponse value = new QueryResponse(); value.setMaxResults(10); final IntuitResponse response = new IntuitResponse(); response.setQueryResponse(value); final CallbackMessage message = invokeInterceptor(response); assertNotNull(message.getQueryResult()); assertEquals(10, (int)message.getQueryResult().getMaxResults()); }
|
### Question:
PropertyHelper { private PropertyHelper() { } private PropertyHelper(); static synchronized PropertyHelper getInstance(); String getVersion(); void setVersion(String version); String getRequestSource(); void setRequestSource(String requestSource); String getRequestSourceHeader(); void setRequestSourceHeader(String requestSourceHeader); }### Answer:
@Test public void testPropertyHelper() { PropertyHelper propertyHelper = PropertyHelper.getInstance(); Assert.assertNotNull(propertyHelper); }
|
### Question:
PSECentralObjectProvider implements CentralObjectProvider { @Override public ElectionDescriptionSource getElectionDescriptionSource() { return cElectionEditor; } PSECentralObjectProvider(BEASTCommunicator communicator); @Override ElectionDescriptionSource getElectionDescriptionSource(); @Override PreAndPostConditionsDescriptionSource getPreAndPostConditionsSource(); @Override ResultCheckerCommunicator getResultCheckerCommunicator(); @Override ParameterSource getParameterSrc(); @Override ResultPresenter getResultPresenter(); @Override MainNotifier getMainNotifier(); @Override CheckStatusDisplay getCheckStatusDisplay(); ParameterEditor getParameterEditor(); void setCheckerCommunicator(ResultCheckerCommunicator checkerCommunicator); @Override CElectionDescriptionEditor getCElectionEditor(); }### Answer:
@Test public void testGetElectionDescriptionSource() { System.out.println("createObjects - PSECentralObjectProvider"); PSECentralObjectProvider instance = new PSECentralObjectProvider(new BEASTCommunicator()); ElectionDescriptionSource failResultEDS = null; ElectionDescriptionSource resultEDS = instance.getElectionDescriptionSource(); assertNotEquals(failResultEDS, resultEDS); PreAndPostConditionsDescriptionSource failResultPNP = null; PreAndPostConditionsDescriptionSource resultPNP = instance.getPreAndPostConditionsSource(); assertNotEquals(failResultPNP, resultPNP); ResultCheckerCommunicator failResultRCC = null; ResultCheckerCommunicator resultRCC = instance.getResultCheckerCommunicator(); assertNotEquals(failResultRCC, resultRCC); ParameterSource failResultPS = null; ParameterSource resultPS = instance.getParameterSrc(); assertNotEquals(failResultPS, resultPS); ResultPresenter failResultRP = null; ResultPresenter resultRP = instance.getResultPresenter(); assertNotEquals(failResultRP, resultRP); MainNotifier failResultMN = null; MainNotifier resultMN = instance.getMainNotifier(); assertNotEquals(failResultMN, resultMN); CheckStatusDisplay failResultCSD = null; CheckStatusDisplay resultCSD = instance.getCheckStatusDisplay(); assertNotEquals(failResultCSD, resultCSD); }
|
### Question:
CheckerFactoryFactory { public static CheckerFactory getCheckerFactory(String checkerID, FactoryController controller, ElectionDescriptionSource electionDescSrc, PreAndPostConditionsDescription postAndPrepPropDesc, ParameterSource paramSrc, Result result, boolean isMargin) { init(); if (factories.keySet().contains(checkerID)) { return factories.get(checkerID).getNewInstance(controller, electionDescSrc, postAndPrepPropDesc, paramSrc, result, isMargin); } else { ErrorLogger.log("The specified checkerID wasn't found"); return null; } } private CheckerFactoryFactory(); static List<String> getAvailableCheckerIDs(); static PropertyChecker createPropertyChecker(String checkerID); static CheckerFactory getCheckerFactory(String checkerID, FactoryController controller,
ElectionDescriptionSource electionDescSrc, PreAndPostConditionsDescription postAndPrepPropDesc,
ParameterSource paramSrc, Result result, boolean isMargin); static CheckerFactory getCheckerFactory(String checkerID, FactoryController controller, File toCheck,
ParameterSource paramSrc, Result result, boolean isMargin); static List<Result> getMatchingResult(String checkerID, int amount); static List<Result> getMatchingUnprocessedResult(String checkerID, int amount); }### Answer:
@Test public void createCheckerfactoryFailure() { CheckerFactory factory = CheckerFactoryFactory.getCheckerFactory("nicht_cbmc", null, null, null, null, null, false); assertNull(factory); }
@Test public void createCheckerfactorySuccess() { CheckerFactory factory = CheckerFactoryFactory.getCheckerFactory("cbmc", null, null, null, null, null, false); assertNotNull(factory); assertTrue(factory instanceof CBMCProcessFactory); }
|
### Question:
CBMCProcessFactory extends CheckerFactory { @Override public boolean checkAssertionSuccess(List<String> toCheck) { if (toCheck != null && toCheck.size() > 0) { return toCheck.get(toCheck.size() - 1).contains(SUCCESSLINE); } else { return false; } } protected CBMCProcessFactory(FactoryController controller, ElectionDescriptionSource electionDescSrc,PreAndPostConditionsDescription postAndPrepPropDesc, ParameterSource paramSrc, Result result, boolean isMargin); CBMCProcessFactory(FactoryController controller, File toCheck, ParameterSource paramSrc, Result result, boolean isMargin); @Override boolean checkAssertionSuccess(List<String> toCheck); @Override boolean checkAssertionFailure(List<String> toCheck); @Override CheckerFactory getNewInstance(FactoryController controller, ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, ParameterSource paramSrc, Result result, boolean isMargin); @Override CheckerFactory getNewInstance(FactoryController controller, File toCheck, ParameterSource paramSrc,
Result result, boolean isMargin); @Override List<Result> getMatchingResult(int amount); File createCodeFileCheck(ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, boolean isMargin); File createCodeFileMargin(ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, int margin, List<String> origResult, boolean isTest); }### Answer:
@Test public void successSuccesTest() { List<String> toTest = new ArrayList<String>(); toTest.add("VERIFICATION SUCCESSFUL"); assertTrue(prosFac.checkAssertionSuccess(toTest)); }
@Test public void succesFailureTest() { assertFalse(prosFac.checkAssertionSuccess(null)); }
|
### Question:
CBMCProcessFactory extends CheckerFactory { @Override public boolean checkAssertionFailure(List<String> toCheck) { if (toCheck != null && toCheck.size() > 0) { return toCheck.get(toCheck.size() - 1).contains(FAILURELINE); } else { return false; } } protected CBMCProcessFactory(FactoryController controller, ElectionDescriptionSource electionDescSrc,PreAndPostConditionsDescription postAndPrepPropDesc, ParameterSource paramSrc, Result result, boolean isMargin); CBMCProcessFactory(FactoryController controller, File toCheck, ParameterSource paramSrc, Result result, boolean isMargin); @Override boolean checkAssertionSuccess(List<String> toCheck); @Override boolean checkAssertionFailure(List<String> toCheck); @Override CheckerFactory getNewInstance(FactoryController controller, ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, ParameterSource paramSrc, Result result, boolean isMargin); @Override CheckerFactory getNewInstance(FactoryController controller, File toCheck, ParameterSource paramSrc,
Result result, boolean isMargin); @Override List<Result> getMatchingResult(int amount); File createCodeFileCheck(ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, boolean isMargin); File createCodeFileMargin(ElectionDescriptionSource electionDescSrc,
PreAndPostConditionsDescription postAndPrepPropDesc, int margin, List<String> origResult, boolean isTest); }### Answer:
@Test public void failureSuccesTest() { List<String> toTest = new ArrayList<String>(); toTest.add("VERIFICATION FAILED"); assertTrue(prosFac.checkAssertionFailure(toTest)); }
@Test public void failFailureTest() { assertFalse(prosFac.checkAssertionFailure(null)); }
|
### Question:
PropertyListStringResProvider extends StringResourceProvider { public StringResourceLoader getMenuStringRes() { return menuStringRes; } PropertyListStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetMenuStringRes() { System.out.println("getMenuStringRes"); StringResourceLoader result = instance.getMenuStringRes(); assertEquals("Ergebnis anzeigen", result.getStringFromID("showResult")); }
|
### Question:
PropertyListStringResProvider extends StringResourceProvider { public StringResourceLoader getToolbarTipStringRes() { return toolbarTipStringRes; } PropertyListStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetToolbarTipStringRes() { System.out.println("getToolbarTipStringRes"); StringResourceLoader result = instance.getToolbarTipStringRes(); assertEquals("Neu", result.getStringFromID("addNew")); }
|
### Question:
PropertyListStringResProvider extends StringResourceProvider { public StringResourceLoader getOtherStringRes() { return otherStringRes; } PropertyListStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetOtherStringRes() { System.out.println("getOtherStringRes"); StringResourceLoader result = instance.getOtherStringRes(); assertEquals("Stimmenauszählung", result.getStringFromID("electionpoints")); }
|
### Question:
PropertyListStringResProvider extends StringResourceProvider { @Override protected final void initialize() { toolbarTipStringRes = this.getStringResourceLoaderFromModuleName("PropertyListToolbar"); menuStringRes = this.getStringResourceLoaderFromModuleName("PropertyListMenu"); otherStringRes = this.getStringResourceLoaderFromModuleName("PropertyListOther"); } PropertyListStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); this.testGetMenuStringRes(); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getMenuStringRes() { return menuStringRes; } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testGetMenuStringRes() { System.out.println("getMenuStringRes"); StringResourceLoader result = instance.getMenuStringRes(); assertEquals("Datei", result.getStringFromID("fileMenu")); }
|
### Question:
SaverLoaderHelper { public String getStringForAttr(String attrName, String content) { return attrName.length() + " " + attrName + content.length() + " " + content; } String getStringForAttr(String attrName, String content); String getStringForAttr(String attrName, int content); String getStringForAttr(String attrName, List<String> content); Map<String, String> parseSaveString(String saveFile); }### Answer:
@Test public void testCreateSaveString() { String s = h.getStringForAttr("name", "Jack"); assertEquals("4 name4 Jack", s); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getBooleanExpEditorSymbVarListRes() { return booleanExpEditorSymbVarListRes; } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testGetBooleanExpEditorSymbVarListRes() { System.out.println("getBooleanExpEditorSymbVarListRes"); StringResourceLoader result = instance.getBooleanExpEditorSymbVarListRes(); assertEquals("Wähler", result.getStringFromID("VOTER")); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getToolbarTipStringRes() { return toolbarTipStringRes; } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testGetToolbarTipStringRes() { System.out.println("getToolbarTipStringRes"); StringResourceLoader result = instance.getToolbarTipStringRes(); assertEquals("Neue Eigenschaft", result.getStringFromID("new")); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getBooleanExpErrorStringRes() { return booleanExpErrorStringRes; } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testGetBooleanExpErrorStringRes() { System.out.println("getBooleanExpErrorStringRes"); StringResourceLoader result = instance.getBooleanExpErrorStringRes(); assertEquals("Fehler", result.getStringFromID("error")); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getBooleanExpEditorWindowStringRes() { return booleanExpEditorWindow; } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testGetBooleanExpEditorWindowStringRes() { System.out.println("getBooleanExpEditorWindowStringRes"); StringResourceLoader result = instance.getBooleanExpEditorWindowStringRes(); assertEquals("Eigenschafteneditor", result.getStringFromID("windowTitle")); }
|
### Question:
BooleanExpEditorStringResProvider extends StringResourceProvider { @Override protected final void initialize() { toolbarTipStringRes = this.getStringResourceLoaderFromModuleName("BooleanExpEditorToolbar"); menuStringRes = this.getStringResourceLoaderFromModuleName("BooleanExpEditorMenu"); booleanExpErrorStringRes = this.getStringResourceLoaderFromModuleName("BooleanExpEditorBooleanExpError"); booleanExpEditorWindow = this.getStringResourceLoaderFromModuleName("BooleanExpEditorWindow"); booleanExpEditorSymbVarListRes = this.getStringResourceLoaderFromModuleName("BooleanExpEditorSymbVarList"); } BooleanExpEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getBooleanExpEditorSymbVarListRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getBooleanExpErrorStringRes(); StringResourceLoader getBooleanExpEditorWindowStringRes(); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); this.testGetBooleanExpEditorSymbVarListRes(); }
|
### Question:
ParameterEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getMenuStringRes() { return menuStringRes; } ParameterEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetMenuStringRes() { System.out.println("getMenuStringRes"); StringResourceLoader result = instance.getMenuStringRes(); assertEquals("Neues Projekt", result.getStringFromID("new")); }
|
### Question:
ParameterEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getToolbarTipStringRes() { return toolbarTipStringRes; } ParameterEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetToolbarTipStringRes() { System.out.println("getToolbarTipStringRes"); StringResourceLoader result = instance.getToolbarTipStringRes(); assertEquals("Stoppe Analyse", result.getStringFromID("stop")); }
|
### Question:
ParameterEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getOtherStringRes() { return otherStringRes; } ParameterEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testGetOtherStringRes() { System.out.println("getOtherStringRes"); StringResourceLoader result = instance.getOtherStringRes(); assertEquals("Dauer", result.getStringFromID("timeout")); }
|
### Question:
ParameterEditorStringResProvider extends StringResourceProvider { @Override protected final void initialize() { toolbarTipStringRes = this.getStringResourceLoaderFromModuleName("ParameterEditorToolbar"); menuStringRes = this.getStringResourceLoaderFromModuleName("ParameterEditorMenu"); otherStringRes = this.getStringResourceLoaderFromModuleName("ParameterEditorOther"); } ParameterEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getOtherStringRes(); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); this.testGetMenuStringRes(); }
|
### Question:
StringResourceLoader { public String getStringFromID(String id) { String get = idsToString.get(id.toLowerCase()); if (get == null) { ErrorLogger.log("this Id was not found in a Stringfile: " + id.toLowerCase()); } return get; } StringResourceLoader(LinkedList<String> stringRes); String getStringFromID(String id); String getIdForString(String s); boolean containsId(String id); }### Answer:
@Test public void testGetStringFromID() { System.out.println("getStringFromID"); String id = "test"; String id2 = "test2"; String result = instance.getStringFromID(id); assertEquals("this is a test", result); String result2 = instance.getStringFromID(id2); assertEquals("also a test", result2); instance.getStringFromID(null); }
|
### Question:
StringResourceLoader { public String getIdForString(String s) { if (idsToString.containsValue(s)) { for (Entry<String, String> entry : idsToString.entrySet()) { if (Objects.equals(s.toLowerCase(), entry.getValue().toLowerCase())) { return entry.getKey(); } } } return null; } StringResourceLoader(LinkedList<String> stringRes); String getStringFromID(String id); String getIdForString(String s); boolean containsId(String id); }### Answer:
@Test public void testGetIdForString() { System.out.println("getIdForString"); String s = "not in the testfile"; String result = instance.getIdForString(s); assertEquals(null, result); result = instance.getIdForString("this is a test"); assertEquals("test", result); result = instance.getIdForString("also a test"); assertEquals("test2", result); instance.getStringFromID(null); }
|
### Question:
StringResourceLoader { public boolean containsId(String id) { return idsToString.containsKey(id.toLowerCase()); } StringResourceLoader(LinkedList<String> stringRes); String getStringFromID(String id); String getIdForString(String s); boolean containsId(String id); }### Answer:
@Test public void testContainsId() { System.out.println("containsId"); String id = "teeeest"; boolean result = instance.containsId(id); assertEquals(false, result); result = instance.containsId("test"); assertEquals(true, result); result = instance.containsId("test2"); assertEquals(true, result); instance.containsId(null); }
|
### Question:
CElectionEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getMenuStringRes() { return menuStringRes; } CElectionEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getCErrorStringRes(); StringResourceLoader getElectionStringRes(); }### Answer:
@Test public void testGetMenuStringRes() { System.out.println("getMenuStringRes"); StringResourceLoader result = instance.getMenuStringRes(); assertEquals("Datei", result.getStringFromID("file")); }
|
### Question:
CElectionEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getToolbarTipStringRes() { return toolbarTipStringRes; } CElectionEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getCErrorStringRes(); StringResourceLoader getElectionStringRes(); }### Answer:
@Test public void testGetToolbarTipStringRes() { System.out.println("getToolbarTipStringRes"); StringResourceLoader result = instance.getToolbarTipStringRes(); assertEquals("Speichern", result.getStringFromID("save")); }
|
### Question:
CElectionEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getCErrorStringRes() { return cErrorStringRes; } CElectionEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getCErrorStringRes(); StringResourceLoader getElectionStringRes(); }### Answer:
@Test public void testGetCErrorStringRes() { System.out.println("getCErrorStringRes"); StringResourceLoader result = instance.getCErrorStringRes(); assertEquals("Zeile", result.getStringFromID("line")); }
|
### Question:
CElectionEditorStringResProvider extends StringResourceProvider { @Override protected final void initialize() { toolbarTipStringRes = this.getStringResourceLoaderFromModuleName("CElectionEditorToolbar"); menuStringRes = this.getStringResourceLoaderFromModuleName("CElectionEditorMenu"); cErrorStringRes = this.getStringResourceLoaderFromModuleName("CElectionEditorCError"); electionStringRes = this.getStringResourceLoaderFromModuleName("CElectionEditorElection"); } CElectionEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getCErrorStringRes(); StringResourceLoader getElectionStringRes(); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); this.testGetCErrorStringRes(); }
|
### Question:
CElectionEditorStringResProvider extends StringResourceProvider { public StringResourceLoader getElectionStringRes() { return electionStringRes; } CElectionEditorStringResProvider(String languageId); StringResourceLoader getMenuStringRes(); StringResourceLoader getToolbarTipStringRes(); StringResourceLoader getCErrorStringRes(); StringResourceLoader getElectionStringRes(); }### Answer:
@Test public void testGetElectionStringRes() { System.out.println("getElectionStringRes"); StringResourceLoader result = instance.getElectionStringRes(); assertEquals("Erstellen", result.getStringFromID("create")); }
|
### Question:
StringResourceProvider { public void changeLanguage(String languageId) { this.languageId = languageId; this.initialize(); } StringResourceProvider(String languageId); void changeLanguage(String languageId); }### Answer:
@Test public void testChangeLanguage() { System.out.println("changeLanguage"); String languageId = "test2"; instance.changeLanguage(languageId); StringResourceLoader result = instance.getStringRes(); assert (result.containsId("testo")); assert (result.containsId("testo2")); assertEquals("es un testo", result.getStringFromID("testo")); assertEquals("es un testo tambien", result.getStringFromID("testo2")); instance.changeLanguage("test"); }
|
### Question:
StringResourceProvider { protected abstract void initialize(); StringResourceProvider(String languageId); void changeLanguage(String languageId); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); StringResourceLoader result = instance.getStringRes(); assert (result.containsId("test")); assert (result.containsId("test2")); assertEquals("this is a test", result.getStringFromID("test")); assertEquals("also a test", result.getStringFromID("test2")); }
|
### Question:
StringResourceProvider { protected final StringResourceLoader getStringResourceLoaderFromModuleName(String moduleName) { String subFolderAndFilename = getFileLocationString(moduleName); String superFolder = SuperFolderFinder.getSuperFolder(); String location = superFolder + subFolderAndFilename; File file = new File(location); { LinkedList<String> inputList; try { inputList = FileLoader.loadFileAsString(file); return new StringResourceLoader(inputList); } catch (IOException ex) { fileNotFound(file); } catch (IndexOutOfBoundsException ie) { errorFileHasWrongFormat(file); } } return null; } StringResourceProvider(String languageId); void changeLanguage(String languageId); }### Answer:
@Test public void testGetStringResourceLoaderFromModuleName() { System.out.println("getStringResourceLoaderFromModuleName"); String moduleName = "Testmodul"; StringResourceLoader result = instance.getStringResourceLoaderFromModuleName(moduleName); LinkedList<String> inputList = new LinkedList<>(); inputList.add("test : this is a test"); inputList.add("test2 : also a test"); StringResourceLoader exp = new StringResourceLoader(inputList); assertEquals(exp.containsId("test"), result.containsId("test")); assertEquals(exp.containsId("test2"), result.containsId("test2")); assertEquals(exp.getIdForString("test"), result.getIdForString("test")); assertEquals(exp.getIdForString("test2"), result.getIdForString("test2")); }
|
### Question:
StringLoaderInterface { public PropertyListStringResProvider getPropertyListStringResProvider() { return propListStr; } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testGetPropertyListStringResProvider() { System.out.println("getPropertyListStringResProvider"); PropertyListStringResProvider result = instance.getPropertyListStringResProvider(); assert (result != null); }
|
### Question:
StringLoaderInterface { public BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider() { return booleanExpStr; } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testGetBooleanExpEditorStringResProvider() { System.out.println("getBooleanExpEditorStringResProvider"); BooleanExpEditorStringResProvider result = instance.getBooleanExpEditorStringResProvider(); assert (result != null); }
|
### Question:
StringLoaderInterface { public CElectionEditorStringResProvider getCElectionEditorStringResProvider() { return cElecStr; } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testGetCElectionEditorStringResProvider() { System.out.println("getCElectionEditorStringResProvider"); CElectionEditorStringResProvider result = instance.getCElectionEditorStringResProvider(); assert (result != null); }
|
### Question:
StringLoaderInterface { public ParameterEditorStringResProvider getParameterEditorStringResProvider() { return paramEdStr; } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testGetParameterEditorStringResProvider() { System.out.println("getParameterEditorStringResProvider"); ParameterEditorStringResProvider result = instance.getParameterEditorStringResProvider(); assert (result != null); }
|
### Question:
StringLoaderInterface { public OptionStringResProvider getOptionStringResProvider() { return optionStr; } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testGetOptionStringResProvider() { System.out.println("getOptionStringResProvider"); OptionStringResProvider result = instance.getOptionStringResProvider(); assert (result != null); }
|
### Question:
StringLoaderInterface { public void setLanguage(String languageId) { propListStr.changeLanguage(languageId); booleanExpStr.changeLanguage(languageId); cElecStr.changeLanguage(languageId); paramEdStr.changeLanguage(languageId); optionStr.changeLanguage(languageId); } StringLoaderInterface(String languageId); PropertyListStringResProvider getPropertyListStringResProvider(); BooleanExpEditorStringResProvider getBooleanExpEditorStringResProvider(); CElectionEditorStringResProvider getCElectionEditorStringResProvider(); ParameterEditorStringResProvider getParameterEditorStringResProvider(); OptionStringResProvider getOptionStringResProvider(); void setLanguage(String languageId); }### Answer:
@Test public void testSetLanguage() { System.out.println("setLanguage"); instance.setLanguage("test"); }
|
### Question:
OptionStringResProvider extends StringResourceProvider { public StringResourceLoader getOptionStringRes() { return optionStringRes; } OptionStringResProvider(String languageId); StringResourceLoader getOptionStringRes(); }### Answer:
@Test public void testGetOptionStringRes() { System.out.println("getOptionStringRes"); StringResourceLoader result = instance.getOptionStringRes(); assertEquals("Sprache", result.getStringFromID("lang")); }
|
### Question:
OptionStringResProvider extends StringResourceProvider { @Override protected final void initialize() { optionStringRes = this.getStringResourceLoaderFromModuleName("Option"); } OptionStringResProvider(String languageId); StringResourceLoader getOptionStringRes(); }### Answer:
@Test public void testInitialize() { System.out.println("initialize"); instance.initialize(); this.testGetOptionStringRes(); }
|
### Question:
FileLoader { public static LinkedList<String> loadFileAsString(File file) throws FileNotFoundException, IOException { LinkedList<String> stringlist; InputStream inputStream = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); stringlist = new LinkedList<>(); String line; line = br.readLine(); while (line != null) { stringlist.add(line); line = br.readLine(); } br.close(); return stringlist; } private FileLoader(); static LinkedList<String> loadFileAsString(File file); static BufferedImage loadFileAsImage(File toRead); static synchronized String getNewUniqueName(String pathToDir); static List<String> listAllFilesFromFolder(String pathToDir, String endsWith); }### Answer:
@Test public void testLoadFileAsString() throws Exception { System.out.println("loadFileAsString"); String subFolderAndFilename = "/src/test/testfiles/fileLoaderFileAsStringTest.txt"; String superFolder = SuperFolderFinder.getSuperFolder(); String location = superFolder + subFolderAndFilename; File file = new File(location); LinkedList<String> expResult = new LinkedList<>(); expResult.add("erste Zeile"); expResult.add("zweite Zeile"); expResult.add("ende"); LinkedList<String> result = FileLoader.loadFileAsString(file); assertEquals(expResult.size(), result.size()); for (int i = 0; i < result.size(); i++) { assertEquals(expResult.get(i), result.get(i)); } }
|
### Question:
FileLoader { public static BufferedImage loadFileAsImage(File toRead) { BufferedImage toReturn = null; try { toReturn = ImageIO.read(toRead); } catch (IOException e) { ErrorLogger.log("The specified file: " + toRead.getAbsolutePath() + " couldn't be loaded"); } return toReturn; } private FileLoader(); static LinkedList<String> loadFileAsString(File file); static BufferedImage loadFileAsImage(File toRead); static synchronized String getNewUniqueName(String pathToDir); static List<String> listAllFilesFromFolder(String pathToDir, String endsWith); }### Answer:
@Test public void testLoadFileAsImage() { System.out.println("loadFileAsImage"); File toRead = new File("/src/test/testfiles/eye.png"); BufferedImage expResult = null; BufferedImage result = FileLoader.loadFileAsImage(toRead); try { expResult = ImageIO.read(toRead); } catch (IOException e) { System.out.println("the Testfile eye.png could not be found"); } assertEquals(expResult, result); }
|
### Question:
CVariableErrorFinder implements ErrorFinder { @Override public ArrayList<CodeError> getErrors() { String code = JTextPaneToolbox.getText(pane); ArrayList<String> seperated = new ArrayList<>(); seperated.add("#ifndef V\n #define V 1\n #endif"); seperated.add("#ifndef C\n #define C 1\n #endif"); seperated.add("#ifndef S\n #define S 1\n #endif"); seperated.add("void verify() {}"); seperated.add("void __CPROVER_assert(int x, int y) {}"); seperated.add("void __CPROVER_assume(int x) {}"); seperated.add("struct result { unsigned int arr[S]; };"); seperated.add("struct stack_result { unsigned int arr[C]; };"); seperated.add("void assume(int x) {}"); seperated.add("void assert(int x) {}"); seperated.add("void assert2(int x, int y) {}"); seperated.add("int nondet_int() {return 0;}"); seperated.add("unsigned int nondet_uint() {return 0;}"); seperated.add("unsigned char nondet_uchar() {return 0;}"); seperated.add("char nondet_char() {return 0;}"); seperated.add("int main() {"); seperated.add("}"); String codeSep[] = code.split("\n"); for (int i = 0; i < codeSep.length; i++) { seperated.add(codeSep[i]); } ArrayList<CodeError> found = new ArrayList<>(DeepErrorChecker.checkCodeForErrors(seperated)); return found; } CVariableErrorFinder(JTextPane pane); @Override ArrayList<CodeError> getErrors(); }### Answer:
@Test public void testGetVarNotDeclError() { String code = "void f(){c = 1;}"; pane.setText(code); ArrayList<CodeError> ers = finder.getErrors(); }
|
### Question:
FileLoader { public static synchronized String getNewUniqueName(String pathToDir) { ArrayList<String> usedNames = new ArrayList<>(); File folder = new File(pathToDir.replace("\"", "")); File[] listOfFiles = folder.listFiles(); if (listOfFiles != null) { for (File file : listOfFiles) { if (file.isFile()) { usedNames.add(file.getName()); } } } String newName = getRandomName(100); while (usedNames.contains(newName)) { newName = getRandomName(100); } return newName; } private FileLoader(); static LinkedList<String> loadFileAsString(File file); static BufferedImage loadFileAsImage(File toRead); static synchronized String getNewUniqueName(String pathToDir); static List<String> listAllFilesFromFolder(String pathToDir, String endsWith); }### Answer:
@Test public void testGetNewUniqueName() { System.out.println("getNewUniqueName"); String pathToDir = "/src/test/testfiles/"; ArrayList<String> usedNames = new ArrayList<>(); File folder = new File(pathToDir); File[] listOfFiles = folder.listFiles(); if (listOfFiles != null) { for (File file : listOfFiles) { if (file.isFile()) { usedNames.add(file.getName()); } } } String result = FileLoader.getNewUniqueName(pathToDir); assert (result != null); usedNames.forEach((filename) -> { assert (!(filename.equals(result))); }); }
|
### Question:
CodeArrayListBeautifier { public void add(String addedString) { if (addedString != null) { String tabbed = ""; for (int i = 0; i < numberOfTabs; i++) { tabbed += "\t"; } code.add(tabbed + addedString); } } CodeArrayListBeautifier(); void add(String addedString); void addTab(); void deleteTab(); ArrayList<String> getCodeArrayList(); void addArrayList(List<String> arrayList); void addAll(List<String> votingResultCode); }### Answer:
@Test public void testAdd() { System.out.println("add"); String e = "test"; CodeArrayListBeautifier instance = new CodeArrayListBeautifier(); instance.add(e); assertEquals("test", (instance.getCodeArrayList().get(0))); instance.add(null); }
|
### Question:
CodeArrayListBeautifier { public void addTab() { numberOfTabs++; } CodeArrayListBeautifier(); void add(String addedString); void addTab(); void deleteTab(); ArrayList<String> getCodeArrayList(); void addArrayList(List<String> arrayList); void addAll(List<String> votingResultCode); }### Answer:
@Test public void testAddTab() { System.out.println("addTab"); System.out.println("add"); String e = "test"; CodeArrayListBeautifier instance = new CodeArrayListBeautifier(); instance.addTab(); instance.add(e); assertEquals("\t" + "test", (instance.getCodeArrayList().get(0))); }
|
### Question:
CodeArrayListBeautifier { public void deleteTab() { if (numberOfTabs > 0) { numberOfTabs--; } else { ErrorLogger.log("number of tabs is allready 0"); } } CodeArrayListBeautifier(); void add(String addedString); void addTab(); void deleteTab(); ArrayList<String> getCodeArrayList(); void addArrayList(List<String> arrayList); void addAll(List<String> votingResultCode); }### Answer:
@Test public void testDeleteTab() { System.out.println("deleteTab"); String e = "test"; CodeArrayListBeautifier instance = new CodeArrayListBeautifier(); instance.addTab(); instance.deleteTab(); instance.add(e); assertEquals("test", (instance.getCodeArrayList().get(0))); instance.deleteTab(); e = "test2"; instance.add(e); assertEquals("test2", (instance.getCodeArrayList().get(1))); e = "test3"; instance.addTab(); instance.add(e); instance.deleteTab(); assertEquals("\t" + "test3", (instance.getCodeArrayList().get(2))); }
|
### Question:
CodeArrayListBeautifier { public ArrayList<String> getCodeArrayList() { return code; } CodeArrayListBeautifier(); void add(String addedString); void addTab(); void deleteTab(); ArrayList<String> getCodeArrayList(); void addArrayList(List<String> arrayList); void addAll(List<String> votingResultCode); }### Answer:
@Test public void testGetCodeArrayList() { System.out.println("getCodeArrayList"); String e = "test"; CodeArrayListBeautifier instance = new CodeArrayListBeautifier(); instance.add(e); assertEquals("test", (instance.getCodeArrayList().get(0))); }
|
### Question:
CodeArrayListBeautifier { public void addArrayList(List<String> arrayList) { if (arrayList != null) { arrayList.forEach((singleItem) -> { this.add(singleItem); }); } } CodeArrayListBeautifier(); void add(String addedString); void addTab(); void deleteTab(); ArrayList<String> getCodeArrayList(); void addArrayList(List<String> arrayList); void addAll(List<String> votingResultCode); }### Answer:
@Test public void testAddArrayList() { System.out.println("addArrayList"); ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("2"); arrayList.add("3"); arrayList.add("test"); CodeArrayListBeautifier instance = new CodeArrayListBeautifier(); instance.addArrayList(arrayList); ArrayList<String> resultList = instance.getCodeArrayList(); if (resultList.size() == arrayList.size()) { for (int i = 0; i < arrayList.size(); i++) { assertEquals(resultList.get(i), arrayList.get(i)); } } else { fail("The ArrayLists are of a different size"); } instance.addArrayList(null); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { @Override public String getName() { return this.name; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testGetName() { System.out.println("getName"); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("name"); String expResult = "name"; String result = instance.getName(); assertEquals(expResult, result); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public List<SymbolicVariable> getSymbolicVariableList() { return symbolicVariableList.getSymbolicVariables(); } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testGetSymbolicVariableList() { System.out.println("getSymbolicVariableList"); SymbolicVariableList symbVarList = new SymbolicVariableList(); symbVarList.addSymbolicVariable("test", new InternalTypeContainer(InternalTypeRep.INTEGER)); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("name", null, null, symbVarList); List<SymbolicVariable> result = instance.getSymbolicVariableList(); assertEquals(symbVarList.getSymbolicVariables().get(0), result.get(0)); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public SymbolicVariableList getSymVarList() { return symbolicVariableList; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testGetSymVarList() { System.out.println("getSymVarList"); SymbolicVariableList symbVarList = new SymbolicVariableList(); symbVarList.addSymbolicVariable("test", new InternalTypeContainer(InternalTypeRep.INTEGER)); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("name", null, null, symbVarList); SymbolicVariableList result = instance.getSymVarList(); assertEquals(symbVarList.getSymbolicVariables().get(0), result.getSymbolicVariables().get(0)); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public void setSymbolicVariableList(SymbolicVariableList symbolicVariableList) { this.symbolicVariableList = symbolicVariableList; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testSetSymbolicVariableList() { System.out.println("setSymbolicVariableList"); SymbolicVariableList symbVarList = new SymbolicVariableList(); symbVarList.addSymbolicVariable("test", new InternalTypeContainer(InternalTypeRep.INTEGER)); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("name"); instance.setSymbolicVariableList(symbVarList); SymbolicVariableList result = instance.getSymVarList(); assertEquals(symbVarList.getSymbolicVariables().get(0), result.getSymbolicVariables().get(0)); }
|
### Question:
CheckerFactoryFactory { public static PropertyChecker createPropertyChecker(String checkerID) { init(); if (factories.keySet().contains(checkerID)) { return new PropertyChecker(checkerID); } else { ErrorLogger.log("The specified checkerID wasn't found"); return null; } } private CheckerFactoryFactory(); static List<String> getAvailableCheckerIDs(); static PropertyChecker createPropertyChecker(String checkerID); static CheckerFactory getCheckerFactory(String checkerID, FactoryController controller,
ElectionDescriptionSource electionDescSrc, PreAndPostConditionsDescription postAndPrepPropDesc,
ParameterSource paramSrc, Result result, boolean isMargin); static CheckerFactory getCheckerFactory(String checkerID, FactoryController controller, File toCheck,
ParameterSource paramSrc, Result result, boolean isMargin); static List<Result> getMatchingResult(String checkerID, int amount); static List<Result> getMatchingUnprocessedResult(String checkerID, int amount); }### Answer:
@Test public void createSuccess() { PropertyChecker checker = CheckerFactoryFactory.createPropertyChecker("cbmc"); assertNotNull(checker); }
@Test public void createFailure() { assertNull(CheckerFactoryFactory.createPropertyChecker("nicht_cbmc")); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public FormalPropertiesDescription getPostConditionsDescription() { return postConditionsDescription; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testGetPostConditionsDescription() { System.out.println("getPostConditionsDescription"); FormalPropertiesDescription post = new FormalPropertiesDescription("postTest"); FormalPropertiesDescription pre = new FormalPropertiesDescription("preTest"); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("test", pre, post, null); FormalPropertiesDescription result = instance.getPostConditionsDescription(); assertEquals(post, result); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public FormalPropertiesDescription getPreConditionsDescription() { return preConditionsDescription; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testGetPreConditionsDescription() { System.out.println("getPreConditionsDescription"); FormalPropertiesDescription post = new FormalPropertiesDescription("postTest"); FormalPropertiesDescription pre = new FormalPropertiesDescription("preTest"); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("test", pre, post, null); FormalPropertiesDescription result = instance.getPreConditionsDescription(); assertEquals(pre, result); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription) { this.postConditionsDescription = postConditionsDescription; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testSetPostConditionsDescription() { System.out.println("setPostConditionsDescription"); FormalPropertiesDescription post = new FormalPropertiesDescription("postTest"); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("test"); instance.setPostConditionsDescription(post); FormalPropertiesDescription result = instance.getPostConditionsDescription(); assertEquals(post, result); }
|
### Question:
PreAndPostConditionsDescription implements NameInterface { public void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription) { this.preConditionsDescription = preConditionsDescription; } PreAndPostConditionsDescription(String name); PreAndPostConditionsDescription(String name, FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr); PreAndPostConditionsDescription(String name,
FormalPropertiesDescription preDescr,
FormalPropertiesDescription postDescr, SymbolicVariableList symbolicVariableList); @Override String getName(); List<SymbolicVariable> getSymbolicVariableList(); List<SymbolicVariable> getSymbolicVariablesCloned(); SymbolicVariableList getSymVarList(); void setSymbolicVariableList(SymbolicVariableList symbolicVariableList); FormalPropertiesDescription getPostConditionsDescription(); FormalPropertiesDescription getPreConditionsDescription(); void setPostConditionsDescription(FormalPropertiesDescription postConditionsDescription); void setPreConditionsDescription(FormalPropertiesDescription preConditionsDescription); @Override void setNewName(String newName); }### Answer:
@Test public void testSetPreConditionsDescription() { System.out.println("setPreConditionsDescription"); FormalPropertiesDescription pre = new FormalPropertiesDescription("preTest"); PreAndPostConditionsDescription instance = new PreAndPostConditionsDescription("test"); instance.setPreConditionsDescription(pre); FormalPropertiesDescription result = instance.getPreConditionsDescription(); assertEquals(pre, result); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.