PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Bnsf

Implement CRUD API and tests

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in implementing RESTful CRUD APIs, correct HTTP semantics and content negotiation (text/plain request bodies with JSON responses), robust error handling, and the ability to design unit tests from a function specification to cover edge cases and failure modes.

  • medium
  • Bnsf
  • Software Engineering Fundamentals
  • Software Engineer

Implement CRUD API and tests

Company: Bnsf

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Take-home Project

You are given two software-engineering tasks. 1. Implement a simple REST API for a resource such as `Note` or `Message`. - Support basic CRUD operations: create, read, update, and delete. - The request body for create/update is **raw text**, not JSON, so the input `Content-Type` is `text/plain`. - The API must return appropriate HTTP status codes and JSON responses. - Handle common failure cases such as missing resources, invalid input, and unsupported media types. A reasonable interpretation is: - `POST /items` with `Content-Type: text/plain` creates a new item from the raw text body. - `GET /items/{id}` returns the item if it exists. - `PUT /items/{id}` with `Content-Type: text/plain` replaces the item's content. - `DELETE /items/{id}` removes the item. Even though requests use plain text, all responses should be JSON, for example: - success: `{ "message": "created", "id": 1 }` - error: `{ "message": "item not found" }` 2. Write unit tests for a function when you cannot see the original implementation code. - You only have the function's specification or expected behavior. - Your goal is to design tests that cover as many meaningful scenarios as possible, including edge cases and failure modes. Explain what behaviors should be tested and how you would structure the tests to maximize confidence in correctness.

Quick Answer: This question evaluates proficiency in implementing RESTful CRUD APIs, correct HTTP semantics and content negotiation (text/plain request bodies with JSON responses), robust error handling, and the ability to design unit tests from a function specification to cover edge cases and failure modes.

Bnsf logo
Bnsf
Jan 15, 2026, 12:00 AM
Software Engineer
Take-home Project
Software Engineering Fundamentals
9
0

You are given two software-engineering tasks.

  1. Implement a simple REST API for a resource such as Note or Message .
    • Support basic CRUD operations: create, read, update, and delete.
    • The request body for create/update is raw text , not JSON, so the input Content-Type is text/plain .
    • The API must return appropriate HTTP status codes and JSON responses.
    • Handle common failure cases such as missing resources, invalid input, and unsupported media types.
    A reasonable interpretation is:
    • POST /items with Content-Type: text/plain creates a new item from the raw text body.
    • GET /items/{id} returns the item if it exists.
    • PUT /items/{id} with Content-Type: text/plain replaces the item's content.
    • DELETE /items/{id} removes the item.
    Even though requests use plain text, all responses should be JSON, for example:
    • success: { "message": "created", "id": 1 }
    • error: { "message": "item not found" }
  2. Write unit tests for a function when you cannot see the original implementation code.
    • You only have the function's specification or expected behavior.
    • Your goal is to design tests that cover as many meaningful scenarios as possible, including edge cases and failure modes.

Explain what behaviors should be tested and how you would structure the tests to maximize confidence in correctness.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Bnsf•More Software Engineer•Bnsf Software Engineer•Bnsf Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.